I've not done it, but try calling this method before you call visit().
/**
* Define a set of server variables to be sent with the requests.
*
* @param array $server
* @return $this
*/
protected function withServerVariables(array $server)
{
$this->serverVariables = $server;
return $this;
}
Pass in an array like this:
[
'HTTP_USER_AGENT' => 'User agent string here'
]
or if you want to set it as the header key, user-agent, instead of the server variable key, you'd do something like this:
$headers = [
'user-agent' => 'user agent value here'
];
$this->withServerVariables($this->transformHeadersToServerVars($headers));
// then visit and do whatever else.