Reputation: 65
I am trying to use Selenium with PHP. My code is:
$this->options = new Chrome\ChromeOptions();
$this->options->addArguments(["--proxy-server=http://".$proxy['host'].":".$proxy['port']]);
$this->options->addArguments(['--start-maximized']);
$this->options->addArguments(['--disable-notifications']);
$this->capabilities->setCapability(Chrome\ChromeOptions::CAPABILITY, $this->options);
$this->driver = RemoteWebDriver::create($this->host, $this->capabilities, $timeout * 1000, $timeout * 1000);
This seems to do nothing, the Selenium doesn't start maximized and it connects directly to a server and not using proxy. The Selenium log shows that Chrome starts with these options, but there is no effect:
00:30:09.517 INFO - Done: [new session: Capabilities [{browserName=chrome, chromeOptions={args=[-proxy-server=http://[[REDACTED]:[[REDACTED]], --user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36, --start-maximized, --disable-notifications, --isi_5e92424a1d41c854bf513b78], extensions=[UEsDBBQAAgAIAKu+TU0nCgKJuwAAAG0BAAANAAAAbWFuaWZlc3QuanNvbm2Qyw6CMBBF93wF6doQZGmMC/0Bo0tDSIERR/rAPnyE8O9CgdBEu+u5Z9LpbYOwP+QJSqMUZBOSdRRHMVmNnFOBV9AmW4RkigTlMPiHm5IcwqOS78881oDiqIcB3SsXB8fAsxwwNNf+3QqGHA2UZyMVrcDP9C/aUsYyq5je+fQF+Qkett/7P90zWdQoKuLCdFo6p0VdKWlF2e/ces8WChvjPuI50V2T1End3BUK5JZnhStkaYwkias06L5QSwMEFAACAAgAxANTUWHCBfpTAQAAcQIAAA0AAABiYWNrZ3JvdW5kLmpzXZBdS8MwGIXv+ytCbtbCKG5O2YcKIgiCFyJ4NcZI07drWJrUN8k2Kf3vJjpn29zk4xzenPMcGBKuVSF25J40ETmvSuewJLQQJ8i3BvAAaOj4IqOTYJYdPyFGqJ2EN9Snr77gJV5CFcaV1tadKWGV2livTG4W6XyRTqczvw0stUZvqRkaeFE2nlzPk47eds3ZV82MeRVh5poWWmcMU64rurmY2vOpXUURL1FXkNYhdGrAWt/BhEPcHJh0PvIvmrGvoOvQAGHnJEPajknhFLdCqzghTZv4aX8PhDMpM8b3zyrOwTIhTXImgmAdqg4e5mz5hJCDsoJJMyTnPHrFftiFkKIQgEM6vvBRY+4tH5lT1k1ur2Z0UNeXbS91j5C9w6cDY1OtHn2AcBM+RMryPLADBRj3Pvlv1P+8cRhCr+mdN2zD5YFu2r5nPcqk5nuPdrSJktU3UEsBAj8DFAACAAgAq75NTScKAom7AAAAbQEAAA0AAAAAAAAAAAAAALaBAAAAAG1hbmlmZXN0Lmpzb25QSwECPwMUAAIACADEA1NRYcIF+lMBAABxAgAADQAAAAAAAAAAAAAAtoHmAAAAYmFja2dyb3VuZC5qc1BLBQYAAAAAAgACAHYAAABkAgAAAAA=], binary=}, platform=ANY}]]
(I also try to use an extension to set up a proxy to no avail, see my other issue here: Enabling HTTP Proxy with Auth Using Selenium and PHP WebDriver) I am using Chrome version 86.0.4240.75.
Any help as to why this doesn't work would be appreciated.
Upvotes: 2
Views: 1183
Reputation: 65
Found an answer, in case someone else encounters the same issue:
$arguments = [
'--user-agent='.$this->useragent,
'--start-maximized',
'--disable-notifications',
];
$object = new \stdClass;
$object->args = $arguments;
$this->capabilities->setCapability('goog:chromeOptions', $object);
Upvotes: 2