You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are you trying to achieve? (Expected behavior)
setting chromeOptions
What do you get instead? (Actual behavior)
the options are ignored
How could the issue be reproduced? (Steps to reproduce)
With ChromeDriver 2.31, the option chromeOptions was renamed to goog:chromeOptions.
My code snippet started working as soon as I changed value of the constant Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY to 'goog:chromeOptions'.
Details
Php-webdriver version: 1.5.0
PHP version: 7.1.10
Selenium server version: 3.8.1
Operating system: Linux x86_64
Browser used + version: Chrome 65
Reacted by bscheshirwork, Jens Kohl, George Drak, Dany Maillard, Thomas, Gordon Franke, Eden Reich and happy_ryo
Thanks @maidmaid! I'll try tomorrow. If $arguments equals something similar to ['--headless', '--no-sandbox', '--disable-gpu'], then it looks straight forward.
Thanks to @maidmaid , I organized the walkaround a bit, so if someone face this issue until const will be renamed / added, if at all.
$options = new ChromeOptions;
$capabilities = DesiredCapabilities::chrome();
$host = 'http://selenium-hub:4444/wd/hub';
$arguments = [
// just as an example, this arguments are not required
'--disable-gpu',
'--headless',
'--no-sandbox',
];
$options->addArguments($arguments);
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
// this are the lines of code you need to add
$object = new \stdClass;
$object->args = $arguments;
$capabilities->setCapability('goog:chromeOptions', $object);
That way you set both chromeOptions and goog:chromeOptions(the new name).
Since I'm fairly new to Selenium, I'm just curious as to why this works for us and not those posting in this issue? I verified, \Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY = 'chromeOptions'. So how does that work if ChromeDriver expects 'goog:chromeOptions'?
Php-webdriver version: 1.6.0
PHP version: 7.2.14
Selenium server version: 3.14.0
Selenium Chrome Driver: 2.45
Operating system: Windows 10 x64
Browser used + version: Chrome 71
@laurin1 Define works for us. Are you able to get the network requests?
$webDriver()->manage()->getLog('performance');
If not, then it does not work for you. This issue is about setting Chrome options in order get access to the various non-defaults. The only specific case, that is mentioned here, is the network requests under the performance log.
But you are saying that this issue does not apply to the options I am referring to, correct?
yes.
Sorry if it sounded harsh. The description might be a little misleading. Then main issue is that ChromeDriver has different options settings depending on version as noted in the first comment.
For the normal options this is not an issue since php-webdriver takes care of that for us.
However, if you want to set other options, like getting console.log or network requests, php-webdriver does not help you and you need to know what ChromeDriver expects (depending on version).
Thanks for the detailed explanation. I'm having various issues right now and just trying to understand the various pieces to see what I am missing (and since my results did not match up what I though this issue was explaining, I was even more confused).
@dotnetCarpenter just wanted to point out, I still think it's an issue, and we should make it clear it's all because of the new versions of ChromeDriver that expect goog:chromeOptions in the args list that is sent with curl over HTTP on Remote/HttpCommandExecutor.php therefore, if you decide to set the capability differently (for example as the newer versions of ChromeDriver expecting them $capabilities->setCapability('goog:chromeOptions', $options) the arguments will be ignored.
$capabilities = new DesiredCapabilities();
$options = new ChromeOptions();
$options->addArguments(["window-size=1400,900", "no-sandbox", "headless"]);
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
So as you said, the above works... depending on the version
Activity
maidmaid commentedon Aug 31, 2018
A workaround could be to use
ChromeOptions::setExperimentalOption():maidmaid commentedon Aug 31, 2018
Extra note following my previous comment : if your goal is to enable the performance log, you need this extra instructions :
And then, for getting the logs :
dotnetCarpenter commentedon Dec 11, 2018
@maidmaid Seems like a small error somehow in your code.
ERROR: Facebook\WebDriver\Exception\ExpectedException: invalid argument: perfLoggingPrefs specified, but performance logging was not enabled
ERROR: Facebook\WebDriver\Exception\ExpectedException: invalid argument: cannot parse capability: chromeOptions
from invalid argument: cannot parse perfLoggingPrefs
from invalid argument: unrecognized performance logging option: performance
dotnetCarpenter commentedon Dec 11, 2018
@maidmaid Could you please write the whole snippet or link to the source code that specify the required arguments and types?
maidmaid commentedon Dec 16, 2018
My complete snippet is :
Does it work it now ?
dotnetCarpenter commentedon Dec 17, 2018
Thanks @maidmaid! I'll try tomorrow. If
$argumentsequals something similar to['--headless', '--no-sandbox', '--disable-gpu'], then it looks straight forward.dotnetCarpenter commentedon Dec 20, 2018
@maidmaid Thx! It works beautifully :)
edenreich commentedon Jan 13, 2019
Thanks to @maidmaid , I organized the walkaround a bit, so if someone face this issue until const will be renamed / added, if at all.
That way you set both chromeOptions and goog:chromeOptions(the new name).
laurinkeithdavis commentedon Jan 14, 2019
Not trying to confuse the issue, but doing it this way works fine for us:
Since I'm fairly new to Selenium, I'm just curious as to why this works for us and not those posting in this issue? I verified, \Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY = 'chromeOptions'. So how does that work if ChromeDriver expects 'goog:chromeOptions'?
Php-webdriver version: 1.6.0
PHP version: 7.2.14
Selenium server version: 3.14.0
Selenium Chrome Driver: 2.45
Operating system: Windows 10 x64
Browser used + version: Chrome 71
dotnetCarpenter commentedon Jan 14, 2019
@laurin1 Define works for us. Are you able to get the network requests?
If not, then it does not work for you. This issue is about setting Chrome options in order get access to the various non-defaults. The only specific case, that is mentioned here, is the network requests under the
performancelog.laurinkeithdavis commentedon Jan 14, 2019
Again, I'm new here, so please go easy on me. The original issue says expected behavior is:
With the actual behavior is:
I can set these chrome options:
and verify they are working (well, not sure about the non-sandbox, but I've verified that the other 2 are working.
But you are saying that this issue does not apply to the options I am referring to, correct?
dotnetCarpenter commentedon Jan 14, 2019
yes.
Sorry if it sounded harsh. The description might be a little misleading. Then main issue is that ChromeDriver has different options settings depending on version as noted in the first comment.
For the normal options this is not an issue since php-webdriver takes care of that for us.
the above always works
However, if you want to set other options, like getting
console.logor network requests, php-webdriver does not help you and you need to know what ChromeDriver expects (depending on version).Hence:
the above will give you access to
getLog("browser")andgetLog("performance")getLog("browser")is discussed in #594laurinkeithdavis commentedon Jan 14, 2019
Thanks for the detailed explanation. I'm having various issues right now and just trying to understand the various pieces to see what I am missing (and since my results did not match up what I though this issue was explaining, I was even more confused).
edenreich commentedon Jan 14, 2019
@dotnetCarpenter just wanted to point out, I still think it's an issue, and we should make it clear it's all because of the new versions of ChromeDriver that expect goog:chromeOptions in the args list that is sent with curl over HTTP on
Remote/HttpCommandExecutor.phptherefore, if you decide to set the capability differently (for example as the newer versions of ChromeDriver expecting them$capabilities->setCapability('goog:chromeOptions', $options)the arguments will be ignored.So as you said, the above works... depending on the version
OndraM commentedon Nov 11, 2019
This should be resolved by #673 and fixed in next php-webdriver release.
ingowinkt commentedon Feb 18, 2025
for me this worked:
.setCapability("goog:loggingPrefs", logPrefs);