Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make headless browsers available. #1490

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

Conversation

lpeabody
Copy link
Sponsor Contributor

@lpeabody lpeabody commented May 5, 2021

Changes

  • Makes the following SeleniumHQ-supported headless browsers available for usage within Docksal:
    • Chrome
    • Firefox
    • Edge
  • Browsers can be CPU intensive, so they are disabled by default (even if you've extended them into your docksal.yml file). You must explicitly add COMPOSE_PROFILES="testing" to either docksal.env or docksal-local.env and then run fin up.

@lpeabody lpeabody added the tests Ticket related to creating/fixing tests label May 5, 2021
@lpeabody
Copy link
Sponsor Contributor Author

lpeabody commented May 5, 2021

The chrome browser presents some issues. You may receive a couple of errors immediately:

Tab crash (error is generated from PHPUnit test):

...
WebDriver\Exception\UnknownError: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: chrome=84.0.4147.105)
...

Blocked connection (Docker logs from browser service):

...
browser_1    | Only local connections are allowed.
browser_1    | Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
browser_1    | [Ch1romeD6r2i0v2e3r0 8w1a6s. 5s8t4a]r[tSeEdV EsRuEc]c:e sbsifnudl(l)y .f
browser_1    | ailed: Cannot assign requested address (99)
...

Both of the errors above, based on my testing locally, can be resolved by updating the browser service definition like so:

browser:
    hostname: browser
    image: selenium/standalone-chrome
    environment:
      JAVA_OPTS: "-Dwebdriver.chrome.whitelistedIps="
    shm_size: '512M'
    dns:
      - ${DOCKSAL_DNS1}
      - ${DOCKSAL_DNS2}

Setting shm_size addresses the tab crash, and adding the JAVA_OPTS whitelist equal to nothing allows all remote connections. If we wanted to be more secure we could make the browser service dependent on the cli service and figure out a way to pass the IP address of the cli service on the project network.

For more details regarding the shm_size property usage in the context of the selenium-chrome image, see https://stackoverflow.com/a/53970825/664881.

@lpeabody lpeabody marked this pull request as draft May 5, 2021 16:14
@lmakarov lmakarov closed this Apr 2, 2024
@lmakarov lmakarov deleted the feature/testing-profiles branch April 2, 2024 09:15
@lmakarov lmakarov restored the feature/testing-profiles branch April 2, 2024 12:04
@lmakarov lmakarov reopened this Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Ticket related to creating/fixing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants