Skip to content

Conversation

@titusfortner
Copy link
Member

Most Selenium languages have implemented convenience methods for Headless mode in Chrome & Firefox.

Currently implemented:

  • Ruby - Set
  • JS - Set
  • Java - Set & Unset
  • Python - Set, Unset, Get
  • .NET - N/A

The Chrome Headless mode we've set is not the production browser, and has many limitations (including not being able to load extensions).

Thanks to @mdmintz I learned that Chrome implemented a new Headless mode that is the full production browser:
https://chromium.googlesource.com/chromium/src/+/833543a511a970f44fb074b9f30c6b6268e0be71
It's been available since Chrome 94, but this change should be backwards compatible since it picks up anything it doesn't recognize (e.g., --headless=xx) as just --headless.

There may be slight performance benefit to using the old mode of headless (because it strips out functionality), but I believe the new mode more accurately represents what Selenium should encourage. If we are going to maintain a convenience feature (tbh, I would also be ok with deprecating/removing all of these), then I believe this new mode is the correct one.

I'm not adding Unsetters to Ruby or JS, or Getters to non-Python because I just don't see them as that important. I am implementing Headless in .NET (both Chrome & Firefox) to match Java implementation.

I've verified that the new headless mode works on a Linux box without a GUI / xvfb. I have not evaluated performance.

Which do you prefer:

  1. Accept PR
  2. Keep old implementation
  3. Deprecate convenience method and let users decide
@titusfortner titusfortner added the A-needs decision TLC needs to discuss and agree label Oct 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2022

Codecov Report

Base: 52.31% // Head: 52.31% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (d38d8b2) compared to base (b878a99).
Patch coverage: 50.00% of modified lines in pull request are covered.

Additional details and impacted files
@@ Coverage Diff @@ ## trunk #11099 +/- ## ========================================== - Coverage 52.31% 52.31% -0.01%  ========================================== Files 82 82 Lines 5503 5505 +2 Branches 198 199 +1 ========================================== + Hits 2879 2880 +1  Misses 2426 2426 - Partials 198 199 +1 
Impacted Files Coverage Δ
py/selenium/webdriver/chromium/options.py 71.08% <50.00%> (-0.53%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@harsha509
Copy link
Member

Hi @titusfortner ,

Looks like there is an issue with https://www.w3.org/TR/webdriver/#dfn-print-page when set headless=chrome

The test runs in headless mode but still fails with error WebDriverError: unknown error: PrintToPDF is only supported in headless mode

Is this an issue with chromedriver ?

Thanks,
Sri Harsha

@titusfortner
Copy link
Member Author

@harsha509 yeah, looks like that functionality only works with "old" headless mode, so that's a confounding factor for our decision. I'm also not sure why JS is the only language testing it. :) Was going to look into it more.

@AutomatedTester
Copy link
Member

@harsha509 yeah, looks like that functionality only works with "old" headless mode, so that's a confounding factor for our decision. I'm also not sure why JS is the only language testing it. :) Was going to look into it more.

It's because headless isn't being passed in the new way in the conftest.py file for python. I am assuming the others test setup is similar.

@titusfortner titusfortner marked this pull request as draft October 13, 2022 15:44
@titusfortner titusfortner removed the A-needs decision TLC needs to discuss and agree label Oct 13, 2022
@titusfortner
Copy link
Member Author

It was decided that instead of changing this method that we would mark it as deprecated and advertise using the new mode as the recommended way to run in headless.

@titusfortner titusfortner added this to the 4.6 milestone Oct 13, 2022
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell D 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@titusfortner
Copy link
Member Author

Decided not to do this one, tracking with the new Issue

@diemol
Copy link
Member

diemol commented Dec 22, 2022

Why? I thought we were going to eventually merge this?

@titusfortner
Copy link
Member Author

This PR is wrong. Created new issue to track actual requirement

valfirst added a commit to vividus-framework/vividus that referenced this pull request Dec 23, 2022
valfirst added a commit to vividus-framework/vividus that referenced this pull request Dec 23, 2022
valfirst added a commit to vividus-framework/vividus that referenced this pull request Dec 24, 2022
valfirst added a commit to vividus-framework/vividus that referenced this pull request Dec 24, 2022
valfirst added a commit to vividus-framework/vividus that referenced this pull request Dec 26, 2022
@titusfortner titusfortner deleted the new_headless branch January 12, 2023 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants