Selendroid:未找到元素并引用我未通过的元素ID

时间:2015-07-03 05:57:33

标签: android selenium selendroid

您好我正在使用selendroid来测试我的应用,但我收到错误,其中找不到元素ID ,并且ID显示在我的代码中的任何地方都没有传递错误

以下是TestNG log的追踪:

  

org.openqa.selenium.StaleElementReferenceException:id为' 749f7f36-cf23-cf8a-3ba4-089302016ab6'没找到。命令持续时间或超时:23毫秒有关此错误的文档,请访问:http://seleniumhq.org/exceptions/stale_element_reference.html构建信息:版本:'未知',修订版:'未知',时间:&# 39;未知'系统信息:主机:' admin-PC',ip:' 172.25.14.100',os.name:' Windows 7',os.arch:&# 39; x86',os.version:' 6.1',java.version:' 1.7.0_21'会话ID:75f0​​30b7-cad7-9f00-452d-b29017e502cb驱动信息:io.selendroid.SelendroidDriver功能[{automationName = selendroid,platform = ANY,platformName = android,browserName = selendroid,emulator = false,aut = in.myapp:2.3在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)源)在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)在org.openqa.selenium.remote.RemoteWebDriver .execute(RemoteWebDriver.java:599)在org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)在org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)在融为一体。 selendroid.test.SelendroidTest.bRechargePrepaid(SelendroidTest.java: 116)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)在java.lang.reflect.Method.invoke(未知源)在org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)在org.testng.internal.Invoker.invokeMethod(Invoker.java:648)在org.testng.internal.Invoker.invokeTestMethod(Invoker.java :834)org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)at org.testng.internal.TestMethodWorker.run(TestMethodWorker。 java:108)org.testng.TestRunner.privateRun(TestRunner.java:771)atg.testng.TestRunner.run(TestRunner.java:621)at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)at org.testng.SuiteRun ner.run(SuiteRunner.java:259)org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)org.testng.TestNG.runSuitesSequentially(TestNG) .java:1176)org.testng.TestNG.runSuitesLocally(TestNG.java:1101)atg.testng.TestNG.run(TestNG.java:1009)atg.testng.remote.RemoteTestNG.run(RemoteTestNG.java: 111)org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)引起:io.selendroid.server.common.exceptions.StaleElementReferenceException :id为' 749f7f36-cf23-cf8a-3ba4-089302016ab6'没找到。

我正在为驱动程序添加代码,测试异常发生在recharge_btn id

private SelendroidDriver driver;
    @BeforeClass
        public void setUp() throws Exception {
            SelendroidConfiguration config = new SelendroidConfiguration();
            config.addSupportedApp("myapp.apk");
    //      SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
    //      selendroidServer.launchSelendroid();
            capa = new SelendroidCapabilities("in.myapp:2.3");
            // capa.setAut("io.selendroid.testapp:0.15.0");
            // capa.setPlatformVersion(DeviceTargetPlatform.ANDROID19);
            capa.setEmulator(false);
            driver = new SelendroidDriver(capa);
        }
@Test
    public void bRechargePrepaid() throws Exception {
//      driver = new SelendroidDriver(capa);
        System.out.println("Starting Prepaid Recharge");
        driver.get(PREPAID_RECHARGE_ACTIVITY);
        // WebElement rechargeList = driver.findElement(By.linkText("Prepaid"));
        // rechargeList.click();

//      File file = new File("D:/prepaidRecharge.txt");
//      fr = new FileReader(file);
//      br = new BufferedReader(fr);
//      String fileLine = "";
//      try {
//          while ((fileLine = br.readLine()) != null) {

                WebElement element = driver.findElement(By
                        .id("mobile_number_edit"));
                element.sendKeys("9780325188");
                element = driver.findElement(By.id("amount_edit"));
                element.clear();
                element.sendKeys("100");
                element = driver.findElement(By.id("edt_operator"));
                element.click();
                element = driver
                        .findElement(By.linkText("VODAFONE"));
                element.click();
                Thread.sleep(2000);
                element = driver.findElement(By.id("recharge_btn"));
                element.click();
                element = driver.findElement(By.id("button1"));
                element.click();
                Thread.sleep(15000);
                driver.navigate().back();

//          }
//      } finally {
//          br.close();
//          fr.close();
//      }

        Thread.sleep(10000);

    }

0 个答案:

没有答案