I'm trying to override the user agent string, but couldn't find the solution in the internet so far...
This is my script:
<?php
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('vendor/autoload.php');
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::chrome();
$capabilities->setPlatform(WebDriverPlatform::WINDOWS);
$capabilities->setCapability('userAgent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36');
$capabilities->setCapability('user-agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36');
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
$driver->get('http://localhost/browser-emu/testpage.php?bot=1234');
// wait until the page is loaded
$driver->wait()->until(
WebDriverExpectedCondition::titleContains('register')
);
echo "User agent: " . $driver->findElement(WebDriverBy::cssSelector('#userAgent'))->getText();
$driver->quit();
The page itself is as simple as:
<html>
<body>
<h1>testpage...</h1>
<?php
printf("<div id='userAgent'>%s</div> \n", $_SERVER['HTTP_USER_AGENT']);
?>
</body>
</html>
Doesn't matter what i've already tried, it's always saying the user agent is Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
.
Does anybody know how I can override that?
I'm using (on Ubuntu):
- facebook/webdriver @ 1.4.1
- chromedriver @ 2.30.477691