Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching chrome browser application with desktop view in android

I am launching chrome app using the following desired capabilities

DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "Android");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
    capabilities.setCapability("platformVersion", "5.0.2");
    capabilities.setCapability("appPackage", "com.android.chrome");
    capabilities.setCapability("appActivity", "com.google.android.apps.chrome.ChromeTabbedActivity");
    capabilities.setCapability("disable-popup-blocking", true);
    driverC = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

I wish to know the capabilities required to launch chrome app with Request desktop site check box enabled.

Screen for referrence:

enter image description here

like image 756
Venkatesh G Avatar asked Nov 09 '22 05:11

Venkatesh G


1 Answers

In Mobile automation, to automate the browser in Desktop mode we can perform with the help of user-agent.

Steps to follow:

  1. 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)

    Find user agent

  2. 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:

    DesiredCapabilities caps = new DesiredCapabilities();
    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");
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--user-agent=Chrome/74.0.3729.185");
    caps.setCapability(ChromeOptions.CAPABILITY, options);
    url = "http://127.0.0.1:4723/wd/hub";
    driver = new AndroidDriver<>(new URL(url), caps);
    
  3. 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)

like image 191
Ashok kumar Ganesan Avatar answered Nov 15 '22 05:11

Ashok kumar Ganesan