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

Fixes #36978 - Add possibility to use remote webdriver #9952

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dosas
Copy link
Contributor

@dosas dosas commented Dec 13, 2023

In order to easily execute the selenium tests it would be good to have the possibility to use selenium remote webdriver images

docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:119.0

To access the driver via vagrant or a CI docker image the IP address needs to be set using an evironment variable:

SELENIUM_REMOTE_HOST=<ip_of_docker_host>
JS_TEST_DRIVER=selenium_chrome_remote

There are certain environments that require different chrome options to work so it is possible to add them via semicolon separated string as environment variable:

ADDITIONAL_CHROME_OPTIONS="--disable-dev-shm-usage"

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

2 similar comments
@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@evgeni
Copy link
Member

evgeni commented Dec 14, 2023

ok to test

@evgeni
Copy link
Member

evgeni commented Dec 15, 2023

@MariaAga would you mind looking at this? Looks totally reasonable to me, but my knowledge around the integration tests is rather low.

@evgeni evgeni requested a review from MariaAga December 15, 2023 10:51
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #9962 which should provide a cleaner base for this PR.

test/integration_test_helper.rb Outdated Show resolved Hide resolved
test/integration_test_helper.rb Show resolved Hide resolved
test/integration_test_helper.rb Outdated Show resolved Hide resolved
test/test_helper.rb Outdated Show resolved Hide resolved
test/integration_test_helper.rb Outdated Show resolved Hide resolved
@dosas
Copy link
Contributor Author

dosas commented Dec 21, 2023

I have no idea why the labeler fails maybe someone can help?

@evgeni
Copy link
Member

evgeni commented Dec 21, 2023

I have no idea why the labeler fails maybe someone can help?

that's just broken, ignore it for now :)

@dosas dosas force-pushed the feature/remote-selenium-webdriver branch 2 times, most recently from 826ba53 to 40b0f2a Compare December 21, 2023 14:43
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch 4 times, most recently from c369a67 to ac3b724 Compare January 15, 2024 13:56
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small nitpicks.

A bigger question here is how we're testing in GitHub Actions today and if this would actually be better. I don't know the current chromedriver & chrome are installed.

test/integration_test_helper.rb Outdated Show resolved Hide resolved
test/integration_test_helper.rb Outdated Show resolved Hide resolved
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from ac3b724 to d44b14f Compare January 18, 2024 07:57
@dosas dosas requested a review from ekohl January 18, 2024 08:28
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from d44b14f to 59b757a Compare January 18, 2024 12:14
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me reading the code. I hope to find some time to actually play around with this myself.

test/integration_test_helper.rb Outdated Show resolved Hide resolved
test/integration_test_helper.rb Show resolved Hide resolved
test/integration_test_helper.rb Show resolved Hide resolved
test/integration_test_helper.rb Outdated Show resolved Hide resolved
test/integration_test_helper.rb Outdated Show resolved Hide resolved
@dosas dosas requested a review from ekohl January 18, 2024 14:23
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from 59b757a to f871fff Compare January 18, 2024 14:54
@stejskalleos stejskalleos self-assigned this Jan 30, 2024
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch 2 times, most recently from bb361dc to 72a9c95 Compare January 30, 2024 15:34
@dosas
Copy link
Contributor Author

dosas commented Jan 31, 2024

Any news on this?

@stejskalleos stejskalleos removed their assignment Feb 13, 2024
@dosas
Copy link
Contributor Author

dosas commented Mar 12, 2024

@ekohl what do we need to do to get this forward?

@dosas
Copy link
Contributor Author

dosas commented Mar 21, 2024

ping

@dosas
Copy link
Contributor Author

dosas commented Apr 15, 2024

@ekohl Do you need any additional information on the answers from above?

@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from 72a9c95 to faf5a31 Compare May 23, 2024 07:05
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from faf5a31 to 8577c35 Compare June 17, 2024 06:43
@dosas dosas force-pushed the feature/remote-selenium-webdriver branch from 8577c35 to 76f1da7 Compare June 27, 2024 14:28
Comment on lines +95 to +96
def work_around_selenium_file_detector_bug
# see: https://stackoverflow.com/questions/70441796/selenium-webdriver-for-aws-device-farm-error-when-sending-period-keystroke-t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm really pedantic I'd suggest yardoc tags (which we don't use enough in our codebase).

Suggested change
def work_around_selenium_file_detector_bug
# see: https://stackoverflow.com/questions/70441796/selenium-webdriver-for-aws-device-farm-error-when-sending-period-keystroke-t
# @see https://stackoverflow.com/questions/70441796/selenium-webdriver-for-aws-device-farm-error-when-sending-period-keystroke-t
def work_around_selenium_file_detector_bug

Copy link
Contributor Author

@dosas dosas Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change that but shouldn't we add a rubocop for it then and if the community decides that this is a valid cop we can do it like that?

Comment on lines +45 to +53
elsif javascript_driver == :selenium_chrome_headless
options = chrome_options
options.args << '--headless'
Capybara.register_driver :selenium_chrome_headless do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? This should be available by default:
https://github.com/teamcapybara/capybara/blob/0480f90168a40780d1398c75031a255c1819dce8/lib/capybara/registrations/drivers.rb#L31-L42

I had hoped to utilize this if possible. Given we don't set the window size elsewhere, I'd be tempted to drop chrome_options. I'm not sure anyone actually uses ADDITIONAL_CHROME_OPTIONS anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember (I touched this code 5 months ago) but the window size was required. Although the discussion if that is needed is IMO out of scope for this PR (can be done in follow up PR)

I'm requiring ADDITIONAL_CHROME_OPTIONS downstream. This will make it more easily configurable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its a good idea to be able to set additonal options which can be used. They are optional. So, if you don't need them, don't set the option and it doesn't hurt.

end
elsif javascript_driver == :selenium_chrome_headless
options = chrome_options
options.args << '--headless'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep this, there's also a dedicated API:

Suggested change
options.args << '--headless'
options.headless!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, can you please explain in more detail?

@stejskalleos stejskalleos removed their request for review July 1, 2024 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants