Launching Chrome Browser Application With Desktop View In Android
Solution 1:
In Mobile automation, to automate the browser in Desktop mode we can perform with the help of user-agent.
Steps to follow:
Find the user agent for your device and browser. In your device/emulator navigate to the find my user agent website and it automatically displays the user agent as below. (make a note of it)
Add the above user agent to the ChromeOptions with the help of --user-agent flag. Then assign the flag option with the desired capabilities as below.
On the user agent you can add all the browsers OR the one you wanted to automate.
CODE:
DesiredCapabilitiescaps=newDesiredCapabilities(); caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0"); caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus_10"); caps.setCapability("chromedriverExecutable","\\driver\\chromedriver_74.exe"); caps.setCapability(MobileCapabilityType.BROWSER_NAME, "chrome"); ChromeOptionsoptions=newChromeOptions(); options.addArguments("--user-agent=Chrome/74.0.3729.185"); caps.setCapability(ChromeOptions.CAPABILITY, options); url = "http://127.0.0.1:4723/wd/hub"; driver = newAndroidDriver<>(newURL(url), caps);
Now run the program and verify the execution. The browser automatically opens in desktop mode on the automation device.
(This was performed with the Java language and similar approach could be performed with the other languages)
Post a Comment for "Launching Chrome Browser Application With Desktop View In Android"