SeasideSt / Parasol

Testing web apps in Smalltalk using Selenium WebDriver.
MIT License
31 stars 16 forks source link

This should make connecting to a selenium cloud grid possible. (works with Browserstack) #40

Closed mattonem closed 3 years ago

mattonem commented 3 years ago

Hello guys,

Please consider the following contribution. The goal is to make Parasol compatible with the Browserstack solution. If you have a browserstack account, you can set up your web browser driver this way

BPRemoteWebDriver serverHost: 'hub-cloud.browserstack.com'.
BPRemoteWebDriver username: 'username'.
BPRemoteWebDriver password: 'yourkey'.
BPRemoteWebDriver scheme: 'https'.
BPRemoteWebDriver serverPort: 443.
option := BPChromeOptions new.
driver := BPRemoteWebDriver new initWithCapabilities: option.
driver quit.

The code might look a little bit janky but the official selenium python remote webdriver, does the same weird dirty thing.

mattonem commented 3 years ago

Okay looks like it doesn't work for gemston... Problem is, I have absolutly no idea how to setup a proper gemston env and the error logged doesn't make sense to me...

jbrichau commented 3 years ago

@mattonem I can take a look at the Gemstone problems for you. It looks like there is just some incompatible methods being used. I will take a peek and let you know. Also: would be great if you give some pointers on how you use Parasol with selenium cloud grid and browserstack!

mattonem commented 3 years ago

Thank you for looking at this gemston issue. About how to use Browserstack for testing, I'm still working on code samples. But overall, you got 2 options.

  1. if your testing website is available on a public IP/hostname, then you can connect using the piece of code I showed you in the previous comment, and use the driver just like if you were connected to local selenium instance (additionally you can use the capabilities generator to run your test from a specefic device, smartphone or tablette)
  2. If your testing website is running on localhost or only available on your private network, then there is small binary programme you can use. It will establish a private connexion from the browserstack servers to your laptop/CICD. Then when running your tests, the whole http/https traffic will resolved from your end, and so, you can connect to localhost. (I'm still working on code examples for this. I let you know I have something worth it.).
mattonem commented 3 years ago

It is not the cleanest ever. I'm still working on it. but here an example of how to test local seaside website.

mattonem commented 3 years ago

@jbrichau It took me a while to get back to it. But I have now a rather stable version of it. If you take a look at the Pharo project browserstack-local-smalltalk, you'll notice it executes 2 tests on the browserstack grid (the first running chrome instance, the second running on an Google Pixel 4), both tests connect to localhost:8080 running a seaside server from the same image.

In order to start a session on Browserstack grid on a google pixel all I need to do is:

BPRemoteWebDriver serverHost: 'hub-cloud.browserstack.com'.
BPRemoteWebDriver username: 'BrowserstackUsername'.
BPRemoteWebDriver password: 'BrowserstackKey'.
BPRemoteWebDriver scheme: 'https'.
BPRemoteWebDriver serverPort: 443.
option := BPGenericOptions new.
option setCapability: 'os_version' to: '11.0'.
option setCapability: 'device' to: 'Google Pixel 4'.
option setCapability: 'real_mobile' to: true.
option setCapability: 'project' to: 'ce-challenge'.
option setCapability: 'name' to: 'smalltalk-test'.
option setCapability: 'build' to: Time now asString. 
driver := BPRemoteWebDriver new initWithCapabilities: option

NB: I implemented BPGenericOptions in my Browserstack local project, that let me defines capabilities that are not Chrome related. It could be included in the Parasol lib.

Finally to access localhost all you need is:

What do you think of this implementation ? There are many other devices/browser available on the browserstack grid (including InternetExplorer). So I think this contribution could be a great addition to Parasol.

here the recording the real Pixel 4 accessing my localhost server https://user-images.githubusercontent.com/1918306/103205039-eff78f00-48f8-11eb-8e22-e1fc36bc34af.mp4

jbrichau commented 3 years ago

That's looking great @mattonem! I'll give it a try this week and integrate the changes asap.

mattonem commented 3 years ago

Hi @jbrichau. Any update on this contribution ? Please let me know if you need me to change anything or if you want some additional explanation around it.

jbrichau commented 3 years ago

Hi @mattonem Sorry, I got busy on updating Seaside for Pharo9 and did not get to this PR yet. As I am working my way through the PRs I will definitely get to this one soon.

jbrichau commented 3 years ago

@mattonem sorry for the long wait. Since the travis-ci build is erroring anyway, I'm merging it in and will take it forward from there with the github actions CI builds and see what needs fixing.

Thanks!!