-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Headless mode #805
Headless mode #805
Conversation
@mmartinsky feel free to add comments on the proposed solution for headless mode. @alexcjohnson we can probably switch all integration with headless mode too, it's faster. I will test more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
Thanks @byronz ! Looking forward to release - do you happen to have any idea on release cadence post 1.0.0? |
@staticmethod | ||
def _get_chrome(): | ||
options = Options() | ||
options.add_argument("--no-sandbox") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we lost --no-sandbox
, is it important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I removed this part as the options are fully configurable after this PR
action="store", | ||
default=False, | ||
help="Run tests in headless mode", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use "store_true"
so you can simplify to pytest --headless
, rather than pytest --headless True
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I like the shorter version
@mmartinsky we have some internal discussion right now, nothing official yet, but 2-6 weeks, might be less frequent than last few months. |
hey @byronz and @alexcjohnson, do you have an example of altering the options for the webdriver? For background, I'm running into I found heroku/heroku-buildpack-google-chrome#46 (comment) that seems to be the same issue, I'm hoping that adding these options will clear this up. The command I'm running is I added a
Output:
Our docker image is using Chrome v. |
I'll let @byronz comment on using the options, but I'll note a (sporadic) If you're seeing a consistent failure, the options may be necessary; if it's sporadic the auto-retry may fix it. |
@mmartinsky good point about the how-to, I added the issue for doc enhancement. a sample hook, I put this in a from selenium.webdriver.chrome.options import Options
def pytest_setup_options():
"""called before webdriver is initialized"""
options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
return options and you can verify the options by increasing the logging level Test session starts (platform: darwin, Python 3.7.4, pytest 4.6.4, pytest-sugar 0.9.2)
cachedir: .pytest_cache
rootdir: /Users/byron/code/dash, inifile: pytest.ini
plugins: sugar-0.9.2, mock-1.10.4, dash-1.0.1
collecting ...
------------------------------------------- live log setup --------------------------------------------
22:49:19 | DEBUG | selenium.webdriver.remote.remote_connection:388 | POST http://127.0.0.1:49395/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "chrome", "platformName": "any", "goog:chromeOptions": {"prefs": {"download.default_directory": "/private/var/folders/fl/dx4zhxfn11n3bbrrd7_hwhdr0000gn/T/pytest-of-byron/pytest-36/test_dvui001_disable_props_che0/download", "download.prompt_for_download": false, "download.directory_upgrade": true, "safebrowsing.enabled": false, "safebrowsing.disable_download_protection": true}, "extensions": [], "args": ["--no-sandbox", "--disable-dev-shm-usage"]}}}, "desiredCapabilities": {"browserName": "chrome", "version": "", "platform": "ANY", "loggingPrefs": {"browser": "SEVERE"}, "goog:chromeOptions": {"prefs": {"download.default_directory": "/private/var/folders/fl/dx4zhxfn11n3bbrrd7_hwhdr0000gn/T/pytest-of-byron/pytest-36/test_dvui001_disable_props_che0/download", "download.prompt_for_download": false, "download.directory_upgrade": true, "safebrowsing.enabled": false, "safebrowsing.disable_download_protection": true}, "extensions": [], "args": ["--no-sandbox", "--disable-dev-shm-usage"]}}}
we can tell that |
this solves #793
pytest --headless True
, default is FalseContributor Checklist
optionals
CHANGELOG.md