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

[rb] Add helper method to launch Chrome in headless mode. #5478

Closed

Conversation

pulkitsharma07
Copy link
Contributor

@pulkitsharma07 pulkitsharma07 commented Feb 10, 2018

This makes it consistent with Firefox::Options#headless! (Refer: #4762)

Though I agree with @jimevans to not add this API for a single command line argument, but adding this for consistency.

Another thread: #4591

This makes it consistent with Firefox::Options#headless!
Copy link
Contributor

@cgoldberg cgoldberg left a comment

Choose a reason for hiding this comment

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

hmmm... Python bindings awlays passes --disable-gpu along with --headless. https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/chrome/options.py#L161

@pulkitsharma07
Copy link
Contributor Author

pulkitsharma07 commented Feb 10, 2018

Assuming --disable-gpu was added because of reasons present here https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1, what should be the correct approach ? Add the flag only for Windows ? And then remove that later once the issue is resolved.

I feel adding an extra flag (which the end user might not be aware of) might not be always desirable. See, puppeteer/puppeteer#1260 for instance.

@p0deje
Copy link
Member

p0deje commented Feb 12, 2018

Let's add a condition for Windows

add_argument '--headless'
# https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1
add_argument '--disable-gpu' if WebDriver::Platform.windows?

@p0deje p0deje added the C-rb label Feb 12, 2018
subject.add_argument('foo')
subject.add_argument('bar')

expect(subject.args).to eq %w[foo bar]
Copy link
Contributor

@luke-hill luke-hill Feb 12, 2018

Choose a reason for hiding this comment

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

If you're fixing up p0deje's request. can you wrap all your expectations in() instead of space separation and change line 105 to it 'should not add the same argument more than once' do

Due to a chromium issue (https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1),
--disable-gpu flag needs to be set while running chrome headless on
Windows.
@pulkitsharma07
Copy link
Contributor Author

@p0deje, @luke-hill Pushed the changes.

@p0deje
Copy link
Member

p0deje commented Feb 13, 2018

I've merged to master - thank you for PR!

@p0deje p0deje closed this Feb 13, 2018
@cgoldberg
Copy link
Contributor

@luke-hill @p0deje

the Python bindings set --disable-gpu unconditionally. Should Python be changed to only pass it on Windows also?

@luke-hill
Copy link
Contributor

I would guess it's up to the maintainers. It also depends on how the specs are written in python.

@lmtierney You've got visibility of both bindings. What do you think. It does feel superfluous but I'm not a python expert.

@cgoldberg
Copy link
Contributor

just to add some more confusion... have a look at https://bugs.chromium.org/p/chromium/issues/detail?id=737678 , which references:
https://chromium-review.googlesource.com/c/chromium/src/+/522068

"on macOS, so we will
continue to use the physical GPU in headless mode on that platform
(unlike on other platforms where everything is software rendered)."

so... should --disable-gpu be passed on every platform except MacOS? or is this handled internally by Chrome?

@p0deje
Copy link
Member

p0deje commented Feb 13, 2018

This flag is no longer necessary on Linux or macOS. It will become unnecessary on Windows as soon as bug 729961 is fixed.

🤷‍♂️

@lmtierney
Copy link
Member

Currently, Java and Javascript also include the --disable-gpu argument. 🤷‍♂️

@pulkitsharma07
Copy link
Contributor Author

Okay, so chromedriver's python client adds --disable-gpu only for linux (and from what it looks like it, adds that for non headless mode too)
https://github.com/bayandin/chromedriver/blob/master/client/chromedriver.py#L156
🤷‍♂️ 🤷‍♂️

@luke-hill
Copy link
Contributor

From what Alex said earlier. It seems easiest / most-agile to wait until 729961 is fixed and then so a Selenium-wide change to make all the bindings correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants