-
Hi, I'm using pyleniumio 1.12.2 and it seems that the user agent string override option in Chrome isn't respected if the headless option is invoked on the command line. This was tested on
The test:
In this example, pylenium.json with headless option and user-agent override works as expected.
However, if the headless option is invoked on the command line, the user-agent override is not respected.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @chingc, First off, thanks for such a clean and readable Issue! I really appreciate the details and structure because that made it super easy to understand what's going on. Ok, now to the good stuff. I changed this from
This was intentional because it provides pipelines and automation the ability to control the framework rather than having to rely on too many layers. In other words, you can get a lot of the information about the pipeline and its steps by looking at the scripts rather than having to look in multiple places (ie the scripts and pylenium.json), but it's still really flexible. However, I could also see the use case for CLI args appending the cli_browser_options = request.config.getoption('--options')
if cli_browser_options: # if at least one option is passed via CLI
for opt in [option.strip() for option in cli_browser_options.split(',')]:
if opt not in config.driver.options: # if that option is not already in config.driver.options
config.driver.options.append(opt) # then add it Examples
pylenium.json"driver": {
...
"options": []
} commandpytest --options="headless"
# ---or---
pytest --options="--headless"
pylenium.json"driver": {
...
"options": ["incognito"]
} commandpytest --options="headless, incognito"
# ---or---
pytest --options="--headless, --incognito"
"driver": {
...
"options": ["headless"]
} command# nothing to add since pylenium.json handles it
pytest
"driver": {
...
"options": ["user-data-dir=/path/to/your/local/profile"]
} commandpytest --options="user-data-dir=/path/to/your/cloud/profile"
"driver": {
...
"options": ["incognito", "start-maximized]
} command# an underscore or any other character will work
pytest --options="_" I hope that clarifies how things work! Thanks again for taking the time to submit an issue. Let me know what you think 😄 |
Beta Was this translation helpful? Give feedback.
-
@ElSnoMan Thanks for the quick reply. I understand what's going on now, and the examples were especially helpful! |
Beta Was this translation helpful? Give feedback.
Hi @chingc,
First off, thanks for such a clean and readable Issue! I really appreciate the details and structure because that made it super easy to understand what's going on.
Ok, now to the good stuff. I changed this from
bug
todiscussion
because this is expected behavior, but I'm always open to discuss other solutions! Let's break down the order of operations with thePyleniumConfig
object:PyleniumConfig
is created frompylenium.json
Pylenium
is then instantiated with the instance ofPyleniumConfig
This was inten…