Sonal
Sonal

Reputation: 53

Click method is not working with chrome emulator

Below are the details of my setup:

chrome=67.0.3396.87, chromedriver=2.40.565498, selenium version-2.53.0

Below is the emulator code-

public ChromeOptions getChromeEmulators(int width, int height) {
    Map<String, Object> deviceMetrics = new HashMap<String, Object>();
    Map<String, Object> mobileEmulation = new HashMap<String, Object>();
    ChromeOptions chromeOptions = new ChromeOptions();
    try {
        deviceMetrics.put("width", width);           
        deviceMetrics.put("height", height);
        deviceMetrics.put("pixelRatio", 3.0);
        mobileEmulation.put("deviceMetrics", deviceMetrics);
        mobileEmulation.put("userAgent",
"Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) 
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile 
Safari/535.19");
       chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
    }catch (Exception e) {
        e.printStackStarce();
    }
    return chromeOptions;
}

The click option is not working with chrome emulator, but it works on chrome browser with above versions. Can someone help?

Upvotes: 0

Views: 2345

Answers (1)

Sajeel Aafaq
Sajeel Aafaq

Reputation: 51

This is a known issue of chromedriver in existence since the past few versions. No fix yet. At this point, the only workaround is to use chromerdriver : 2.33.506120 + chrome : 61.0.3163.79

Refer to the below bugs :

https://bugs.chromium.org/p/chromedriver/issues/detail?id=2144&desc=2

https://bugs.chromium.org/p/chromedriver/issues/detail?id=2172

Alternatively, u can try JavascriptExecutor (though this is not much preferred)

JavascriptExecutor script click. JavascriptExecutor js = (JavascriptExecutor) 
driver; js.executeScript("arguments[0].click();",element);

Upvotes: 1

Related Questions