ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Click not working in EMULATION from chromedriver2.12 to chromedriver2.14 #1029

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Before I start please note: Click is working perfectly when I don't use 
emulation. Only in emulation I have the problem.

Clicks are not working when I tried to migrate from chromedriver2.11 to Latest. 
I tried chromedriver2.12, chromedriver2.13 and chromedriver2.14, but nothing 
worked for me.

Clicks work if I am not using emulation. But in emulation it is not. I have 
used two types of clicks in emulation mode.

WebElement LogIn;

1. LogIn.click();
2. new Actions(driver).moveToElement(LogIn).click().perform();

Both are not working. Did someone else face this when you use emulation with 
latest chromedrivers(2.12/2.13/2.14)?

Configuration I use
===================
Browser : Chrome 40.0.2214.93 m
Selenium : 2.44.0
Chromedriver : 2.14

Original issue reported on code.google.com by robinsmathew on 5 Feb 2015 at 2:18

GoogleCodeExporter commented 9 years ago
1. what language,  system, etc..  you are using?
2. do you try real device?
3. would you please provide a standalone program that we can verify?

Original comment by andrewch...@chromium.org on 5 Feb 2015 at 6:50

GoogleCodeExporter commented 9 years ago
@andrewch: Thanks a lot for you reply. I will explain you the scenario.

Please find my sample program to test Chromedriver version from 2.12 to 2.14.

Try execute this code against chromedriver2.11 - Works fine
Try execute the same code in chromedriver 2.12,2.13 or 2.14 - Click will not 
work.

Tried in devices, User agents, emulations in manual - Working perfectly.

Let me tell you all the configurations I use:
=============================================
Development : Java, TestNG
Selenium : 2.44.0

My Hub Node configuration
=========================
Hub : start java -jar selenium-server-standalone-2.44.0.jar -role hub 
Node : start java -jar selenium-server-standalone-2.44.0.jar -role webdriver 
-hub http://localhost:4444/grid/register -hubHost localhost -host localhost 
-port 5555 browserName=chrome 
-Dwebdriver.chrome.driver=C:\chromedrivers\chromedriver2.14.exe -maxSession 4

Hope this code I attached gives you a clear picture. Please reply if you want 
any more information.

Original comment by robinsmathew on 6 Feb 2015 at 4:40

Attachments:

GoogleCodeExporter commented 9 years ago
Can you double check the findElement 
By.cssSelector("li[data-nav = LogIn], span[data-nav='LogIn'], 
a[data-nav='LogInPopUp']"))

   if it really point to login.
  I use FireFox driver,  it will not find the element at all(worse than Chrome).
  Chrome return an element, but may not login
  can you try by xpath,  by id etc...?
let me know then we can move on the trouble-shooting 

Original comment by andrewch...@chromium.org on 6 Feb 2015 at 11:42

GoogleCodeExporter commented 9 years ago
I have tried everything. It has nothing to do with the locator. If you want to 
ensure that the locator is the correct one what you can do is 

By.cssSelector("li[data-nav = LogIn], span[data-nav='LogIn'], 
a[data-nav='LogInPopUp']")).getAttribute(innerText)

This will return you 'Log In'

Ignore all that. Can you execute the code without making any change run in 
chrome driver2.11, it works really well.

The issue happens when we use Emulation. If you check it without Emulate option 
by giving the UserAgent also it works.

One other point - Its not only one locator try any locator in the page. Click 
wont work.

Original comment by robinsmathew on 6 Feb 2015 at 11:50

GoogleCodeExporter commented 9 years ago
One Suggestion: Please do try it with Chrome, Not Firefox driver, because the 
issue is with the chromedriver.

Original comment by robinsmathew on 6 Feb 2015 at 11:53

GoogleCodeExporter commented 9 years ago
1. Use Firefox just for me as  reference 
2. tried 2.11 - it does  work.   We are looking into this issue.

Original comment by andrewch...@chromium.org on 10 Feb 2015 at 1:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@andrew: I have done some research on this and found out one scenario it works. 
I have tried it in 3 scenarios.

1. Using the option emulate option - Not Working (File: 
TestingChromeDriver_Device_Emulation.java)

Map<String, String> emulate = new HashMap<String, String>();
emulate.put("deviceName", "Apple iPhone 5");

2. Using the User Agents and Device Metrics - Not Working (File: 
TestingChromeDriver_WithDeviceMatricsOn.java)

Map<String, Object> deviceMetrics = new HashMap<String, Object>();

deviceMetrics.put("width", 375);
deviceMetrics.put("height", 667);
deviceMetrics.put("pixelRatio", 3.0);

Map<String, Object> emulate = new HashMap<String, Object>();

emulate.put("deviceMetrics", deviceMetrics);
emulate.put("userAgent", "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) 
AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d 
Safari/600.1.4");

3. Using only the User Agents and No Device Metrics - Working (File: 
TestingChromeDriverDeviceMatricxOff.java)

emulate.put("userAgent", "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) 
AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d 
Safari/600.1.4");

Original comment by robinsmathew on 13 Feb 2015 at 12:23

Attachments:

GoogleCodeExporter commented 9 years ago
good work!
Do you mean third scenario work for all drivers - 2.12, 2.13, 2.14?

Original comment by andrewch...@chromium.org on 13 Feb 2015 at 6:50

GoogleCodeExporter commented 9 years ago
Yes it works, but I really appreciate if you will debug to see why it's not 
working in emulation. Because it looks like a bug. What do you think?

Original comment by robinsmathew on 13 Feb 2015 at 7:15

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Issue 1035 has been merged into this issue.

Original comment by andrewch...@chromium.org on 13 Feb 2015 at 8:09

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
what emulation device you sue -  emulate.put("deviceName", "Apple iPhone 5");?
How do you set up the  device?

Original comment by andrewch...@chromium.org on 17 Feb 2015 at 12:02

GoogleCodeExporter commented 9 years ago
https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation

I do set it up the way its shown in this.

Original comment by robinsmathew on 17 Feb 2015 at 9:38

GoogleCodeExporter commented 9 years ago
Some updates on this.

This issue happens in some applications where they check from the application 
and finds the device that support touch events on the load, enables "Emulate 
Touch Screen" option. 

And if the application loads on the device that wont support touch events on 
the load, disables "Emulate Touch Screen" option.

Have anyone else came across this situation?

Original comment by robinsmathew on 19 Feb 2015 at 9:02

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 6 Mar 2015 at 11:09

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
for mobileEmulation

instead of using mouse
WebDriver driver = new RemoteWebDriver(hubURL, chromeCapabilities);
driver.findElement(By.cssSelector("li[data-nav = LogIn], 
span[data-nav='LogIn'], a[data-nav='LogInPopUp']")).click();

use Swipe
driver = new SwipeableWebDriver(hubURL, chromeCapabilities);
            TouchScreen touch = ((HasTouchScreen) driver).getTouch();
//
            WebElement element = driver.findElement(
             By.cssSelector("li[data-nav = LogIn], span[data-nav='LogIn'], a[data-nav='LogInPopUp']"));
            Coordinates elementLocation = ((Locatable) element).getCoordinates();
            touch.singleTap(elementLocation);

-----------------------------------------------------------------
public class SwipeableWebDriver extends RemoteWebDriver implements
        HasTouchScreen {
    private RemoteTouchScreen touch;

    public SwipeableWebDriver(URL remoteAddress,
            Capabilities desiredCapabilities) {
        super(remoteAddress, desiredCapabilities);
        touch = new RemoteTouchScreen(getExecuteMethod());
    }

    public TouchScreen getTouch() {
        return touch;
    }
}

Original comment by andrewch...@chromium.org on 9 Mar 2015 at 6:01

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks a lot for the reply. 

I was working on this now. Looks very interesting. But When I tried I got an 
exception 

Underlying driver does not implement advanced user interactions yet

Any idea why is it so? I am using selenium 2.44 with chromedriver 2.14

Original comment by robinsmathew on 9 Mar 2015 at 6:15

GoogleCodeExporter commented 9 years ago
Which version of selenium do you use?

Original comment by robinsmathew on 9 Mar 2015 at 6:24

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sorry,  you may need selenium-api.jar

Original comment by andrewch...@chromium.org on 9 Mar 2015 at 7:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Please find the attachment for my code. and here is my POM,

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.8.7</version>
</dependency>

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>2.44.0</version>
</dependency>

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.44.0</version>
</dependency>

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>2.1.0</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.9</version>
</dependency>

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <type>maven-plugin</type>
</dependency>

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.16</version>
    <type>maven-plugin</type>
</dependency>

Original comment by robinsmathew on 10 Mar 2015 at 4:58

Attachments:

GoogleCodeExporter commented 9 years ago
please provide me the screen shoot of your errors,   so far your codes look 
good to me.

Original comment by andrewch...@chromium.org on 10 Mar 2015 at 5:17

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here is the error that I get.

Original comment by robinsmathew on 10 Mar 2015 at 5:31

Attachments:

GoogleCodeExporter commented 9 years ago
 run your codes in my machine, and it works.
  except two changes

  1. use URL hubURL = new URL("http://127.0.0.1:9515");
       don't use grid for now
  2. By.cssSelector("a[class='login']")); 

  can you test your S/W  in standalone environments for now?

Original comment by andrewch...@chromium.org on 10 Mar 2015 at 6:09

GoogleCodeExporter commented 9 years ago
Tried that as well. Can you please provide me the hub configuration parameters 
that you use?

Original comment by robinsmathew on 11 Mar 2015 at 1:55

GoogleCodeExporter commented 9 years ago
do not use hub+node for now.  launch chromedriver manually.

Original comment by andrewch...@chromium.org on 11 Mar 2015 at 5:24