2 timob TIMOB 于 2016.09.27 11:43 提问

用Selenium自动化测试android wap页面报错 2C

@Test(dataProvider="Data",enabled=true)
public void testBaidu(String userName,String phone) throws InterruptedException {
driver.get("http://..../....");
System.out.println("---=="+driver.getTitle());
driver.findElement(By.id("username"));
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys(userName);
driver.findElement(By.id("mobile")).click();
driver.findElement(By.id("mobile")).clear();
driver.findElement(By.id("mobile")).sendKeys(phone);
driver.findElement(By.xpath(".//*[@id='free_sign']")).click();
if (userName.equals("")||userName==null) {
WebElement ele=driver.findElement(By.xpath("html/body/div[4]"));
System.out.println("---"+ele.getText());
Assert.assertTrue(ele.getText().contains("请输入您的姓名"));
}else if (userName!=null&&phone.equals("")||phone==null) {
WebElement ele=driver.findElement(By.xpath("html/body/div[4]"));
System.out.println("---"+ele.getText());
Assert.assertTrue(ele.getText().contains("请输入您的手机号码"));
}else if (phone.length()11) {
WebElement ele=driver.findElement(By.xpath("html/body/div[4]"));
System.out.println("---"+ele.getText());
Assert.assertTrue(ele.getText().contains("对不起,您输入的手机号码有误"));
}else if (!userName.equals("")&&userName!=null&&phone.length()==11) {
Assert.assertTrue(driver.getCurrentUrl().contains("http://...../...."));
System.out.println("--"+driver.getCurrentUrl());
}

}

org.openqa.selenium.WebDriverException: java.lang.Double cannot be cast to java.lang.Long
Command duration or timeout: 190 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: RemoteWebDriver
Session ID: 1474942130373
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:244)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:77)
at androiddemo.AndroidWap.testBaidu(AndroidWap.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)

1个回答

Mr_dsw
Mr_dsw   Ds   Rxr 2016.09.27 12:29

java.lang.Double cannot be cast to java.lang.Long,类型转换错误,不能讲Double转换为Long

TIMOB
TIMOB 这个我知道,可是我的代码里面没有涉及double或者Long类型,我的参数是string类型的
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片