SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

Xpath does not work on Android 4.3 (Device Samsung Galaxy S4) #6873

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 6873

I am able to identify the same element using Cssselector.
We do have few cases where we need xpath
Wondering if Xpath is not supported on Android 4.3??

Environment:
Samsung Galaxy S4 with 4.3 With android-server-2.38.0.apk installed
selendroid-standalone-0.7.0-with-dependencies added as reference from eclipse

Test Code:
package com.example.tests;

import io.selendroid.SelendroidCapabilities;
import io.selendroid.SelendroidDriver;
import io.selendroid.device.DeviceTargetPlatform;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class test1 {

      /**
      * @param args
      */
      public static void main(String[] args)
            {

       SelendroidCapabilities capa = SelendroidCapabilities.device(DeviceTargetPlatform.ANDROID18,"http://192.168.1.4:8080/wd/hub"
);

                WebDriver driver =null;

                                          try {
                                                driver = new SelendroidDriver("http://192.168.1.4:8080/wd/hub",
capa);
                                          } catch (Exception e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                          } 

                  driver.get("http://docs.seleniumhq.org/projects/webdriver/");
            //    driver.findElement(By.cssSelector("a[title='class in org.openqa.selenium.android']")).click();
                  driver.findElement(By.xpath("//a[@title='class in org.openqa.selenium.android']")).click();

            }

}

Exception:

Exception in thread "main" org.openqa.selenium.WebDriverException: Error: {"message":"Unable
to locate an element with the xpath expression \/\/a[@title='class in org.openqa.selenium.android']
because of the following error:\nError: INVALID_EXPRESSION_ERR: DOM XPath Exception
51"}
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'armv7l',
os.version: '3.4.0-1937946', java.version: '0'
Driver info: driver.version: EventFiringWebDriver
Command duration or timeout: 318 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'WACDTL04TT3081', ip: '135.209.100.16', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.7.0_21'
Session ID: 686dd6f4-20a7-45bd-8e7d-2dc8b5ba6d55
Driver info: io.selendroid.SelendroidDriver
Capabilities [{platform=ANDROID, javascriptEnabled=true, acceptSslCerts=true, emulator=false,
browserName=android, locale=en_US, androidTarget=ANDROID18, rotatable=true, locationContextEnabled=true,
webdriver.remote.sessionid=686dd6f4-20a7-45bd-8e7d-2dc8b5ba6d55, aut=http://192.168.1.4:8080/wd/hub,
version=18, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true,
hasTouchScreen=true, applicationCacheEnabled=true, takesScreenshot=true}]
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
      at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
      at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:404)
      at org.openqa.selenium.By$ByXPath.findElement(By.java:363)
      at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
      at com.example.tests.test1.main(test1.java:39)
Caused by: org.openqa.selenium.WebDriverException: Error: {"message":"Unable to locate
an element with the xpath expression \/\/a[@title='class in org.openqa.selenium.android']
because of the following error:\nError: INVALID_EXPRESSION_ERR: DOM XPath Exception
51"}
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'armv7l',
os.version: '3.4.0-1937946', java.version: '0'
Driver info: driver.version: EventFiringWebDriver
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'WACDTL04TT3081', ip: '135.209.100.16', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: EventFiringWebDriver
      at org.openqa.selenium.android.library.AndroidWebDriver.throwIfError(AndroidWebDriver.java:1024)
      at org.openqa.selenium.android.library.AndroidWebDriver.executeRawScript(AndroidWebDriver.java:895)
      at org.openqa.selenium.android.library.AndroidWebDriver.executeAtom(AndroidWebDriver.java:910)
      at org.openqa.selenium.android.library.AndroidWebElement.lookupElement(AndroidWebElement.java:340)
      at org.openqa.selenium.android.library.AndroidWebElement.access$1(AndroidWebElement.java:335)
      at org.openqa.selenium.android.library.AndroidWebElement$FindByImpl.findElementByXPath(AndroidWebElement.java:257)
      at org.openqa.selenium.android.library.AndroidWebDriver$AndroidFindBy.findElementByXPath(AndroidWebDriver.java:593)
      at org.openqa.selenium.By$ByXPath.findElement(By.java:363)
      at org.openqa.selenium.android.library.AndroidWebDriver.findElement(AndroidWebDriver.java:508)
      at org.openqa.selenium.android.AndroidApkDriver.findElement(AndroidApkDriver.java:70)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:525)
      at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
      at $Proxy1.findElement(Native Method)
      at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:184)
      at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:47)
      at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
      at java.util.concurrent.FutureTask.run(FutureTask.java:234)
      at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:170)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
      at java.lang.Thread.run(Thread.java:841)

Reported by meenapanchu on 2014-01-20 20:16:50

lukeis commented 8 years ago
Please report selendroid issue to [1]

[1] https://github.com/selendroid/selendroid/issues?direction=desc&sort=updated&state=open

Reported by barancev on 2014-01-21 15:05:57

lukeis commented 8 years ago
Thanks
Added the issue
https://github.com/selendroid/selendroid/issues/234

Reported by meenapanchu on 2014-01-21 18:50:33

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:22:00