SeleniumHQ / selenium-google-code-issue-archive

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

Xpaths are not working on Selenium AndroidDriver (Version 2.28) #5445

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 5445

Overview:
Xpaths are not working on Selenium AndroidDriver (Version 2.28)
working fine if element is identified by name or id

Steps to Reproduce:
1. Execute any test case in which an element is identified by Xpath.

Actual Output:
Element is not identified using Xpaths

Expected Output:
Element should be identified using Xpaths.

Selenium version: 2.28.0
OS: Android 2.3.7 
Browser:Selenium AndroidDriver
Browser version:Android-Server-2.21.0.apk

Test Case Code:

package com.core.test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;
import org.testng.annotations.Test;

public class TC2  {

      private static WebDriver driver;

      @Test (groups="run")  
      public void testGmail() throws Exception {
        driver = new AndroidDriver();

        driver.get("http://www.gmail.com");
        Thread.sleep(1500);

        driver.findElement(By.name("Email")).click();
        driver.findElement(By.name("Email")).sendKeys(""); 
        Thread.sleep(1000);
        driver.findElement(By.name("Passwd")).click();
        driver.findElement(By.name("Passwd")).sendKeys("");     
        Thread.sleep(1000);

        driver.findElement(By.xpath("//input[@name='signIn']")).click();

        //driver.findElement(By.name("signIn")).click();

        Thread.sleep(30000);

      }
    }

Error Report:
testGmail
org.openqa.selenium.WebDriverException: Error: {"message":"Unable to locate an element
with the xpath expression \/\/input[@name='signIn'] because of the following error:\nTypeError:
Object #<an HTMLDocument> has no method 'evaluate'"} Build info: version: 'unknown',
revision: 'unknown', time: 'unknown' System info: os.name: 'Linux', os.arch: 'armv7l',
os.version: '2.6.35.7+', java.version: '0' Driver info: driver.version: EventFiringWebDriver
Command duration or timeout: 140 milliseconds Build info: version: '2.28.0', revision:
'18309', time: '2012-12-11 20:21:45' System info: os.name: 'Windows 7', os.arch: 'amd64',
os.version: '6.1', java.version: '1.7.0_07' Session ID: 1365071218240 Driver info:
org.openqa.selenium.android.AndroidDriver Capabilities [{platform=ANDROID, acceptSslCerts=true,
javascriptEnabled=true, handlesAlerts=true, browserName=android, browserConnectionEnabled=true,
webStorageEnabled=true, rotatable=true, locationContextEnabled=true, applicationCacheEnabled=true,
webdriver.remote.sessionid=1365071218240, takesScreenshot=true, version=10}] at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533) at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:302) at
org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:387)
at org.openqa.selenium.By$ByXPath.findElement(By.java:344) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:294)
at com.core.test.TC2.testGmail(TC2.java:28) Caused by: org.openqa.selenium.WebDriverException:
Error: {"message":"Unable to locate an element with the xpath expression \/\/input[@name='signIn']
because of the following error:\nTypeError: Object #<an HTMLDocument> has no method
'evaluate'"} Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System
info: os.name: 'Linux', os.arch: 'armv7l', os.version: '2.6.35.7+', java.version: '0'
Driver info: driver.version: EventFiringWebDriver Build info: version: '2.28.0', revision:
'18309', time: '2012-12-11 20:21:45' System info: os.name: 'Windows 7', os.arch: 'amd64',
os.version: '6.1', java.version: '1.7.0_07' Driver info: driver.version: EventFiringWebDriver
at org.openqa.selenium.android.library.AndroidWebDriver.throwIfError(AndroidWebDriver.java:997)
at org.openqa.selenium.android.library.AndroidWebDriver.executeRawScript(AndroidWebDriver.java:868)
at org.openqa.selenium.android.library.AndroidWebDriver.executeAtom(AndroidWebDriver.java:883)
at org.openqa.selenium.android.library.AndroidWebElement.lookupElement(AndroidWebElement.java:345)
at org.openqa.selenium.android.library.AndroidWebElement.access$1(AndroidWebElement.java:340)
at org.openqa.selenium.android.library.AndroidWebElement$FindByImpl.findElementByXPath(AndroidWebElement.java:262)
at org.openqa.selenium.android.library.AndroidWebDriver$AndroidFindBy.findElementByXPath(AndroidWebDriver.java:592)
at org.openqa.selenium.By$ByXPath.findElement(By.java:344) at org.openqa.selenium.android.library.AndroidWebDriver.findElement(AndroidWebDriver.java:507)
at org.openqa.selenium.android.AndroidApkDriver.findElement(AndroidApkDriver.java:70)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:102)
at $Proxy1.findElement(Native Method) at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:181)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1) at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:151)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019) ... Removed 30 stack frames

Regards
Aabir

Reported by aabir.daneshyar on 2013-04-04 11:29:43

lukeis commented 8 years ago

Reported by barancev on 2013-04-10 20:44:31

lukeis commented 8 years ago
Selenium project no longer supports the AndroidDriver.

Please use Selendroid instead:
http://selendroid.io/webview.html

And log any issues against that project:
https://github.com/selendroid/selendroid/issues

Reported by luke.semerau on 2013-12-26 21:57:36

lukeis commented 8 years ago

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