Not so long ago we had to implement a test case where the user goes to a page with an “unknown” browser.
I had to spend some time to find out the proper configuration and made a small post about it to avoid doing it again.

All you have to do is to change the default user-agent. You can do this by instantiating a new ChromeOptions object and add you user agent as an argument.

Very Short example:

public class SampleTestClass  {

@Test
public void sampleTest(){

ChromeOptions chrome = new ChromeOptions();
chrome.addArguments("user-agent=YOUR_USER_AGENT");

WebDriver driver = new ChromeDriver(chrome);

// you can check your user-agent on this site
driver.get("https://www.whatismybrowser.com/");

driver.quit();
}

Similar Posts from the author: