首页 新闻 会员 周边 捐助

java selenium启动app后,在登录页面定位不到元素。resource-id没错

0
[待解决问题]

Exception in thread "main" org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: '2011-20180118QN', ip: '192.168.11.54', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: D:\Development\workspace\Ap..., appActivity: com.immvp.werewolf.ui.activ..., appPackage: com.immvp.werewolf, browserName: Android, databaseEnabled: false, desired: {app: D:\Development\workspace\Ap..., appActivity: com.immvp.werewolf.ui.activ..., appPackage: com.immvp.werewolf, deviceName: MI 4L TE, noReset: true, noSign: true, platformName: Android, platformVersion: 6.0.1, resetKeyboard: true, unicodeKeyboard: true, uuid: 246c5318}, deviceName: 246c5318, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, noSign: true, platform: LINUX, platformName: LINUX, platformVersion: 6.0.1, resetKeyboard: true, takesScreenshot: true, unicodeKeyboard: true, uuid: 246c5318, warnings: {}, webStorageEnabled: false}
Session ID: 6a356cc9-26e1-43fd-b3d0-302adf2fbd56
*** Element info: {Using=id, value=com.immvp.werewolf:id/btnRight}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:417)
    at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:70)
    at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1)
    at com.dsdj.test.AppiumDemo.main(AppiumDemo.java:65)
阳阳享受阳光~的主页 阳阳享受阳光~ | 菜鸟二级 | 园豆:202
提问于:2018-03-28 10:52
< >
分享
所有回答(1)
0

试试不通过id去定位元素

ycyzharry | 园豆:25683 (高人七级) | 2018-03-28 11:34

非常感谢您的指导。用name和className这两种方式我尝试过了!百度好久也没找到答案,是不是进入到启动页还要加代码进行判断什么的啊?

支持(0) 反对(0) 阳阳享受阳光~ | 园豆:202 (菜鸟二级) | 2018-03-28 11:37

@阳阳享受阳光~: 其实最主要是在定位之前需要等待页面显示元素,试试下面方法:

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElementById...

如果还是有问题 就换个其他app测试吧 有的app登录页面不一样

支持(0) 反对(0) ycyzharry | 园豆:25683 (高人七级) | 2018-03-28 11:43

@ycyzharry: 我之前用的微博  后来用的微信。最后我就拿自己公司的这个app了!结果都报一个错

支持(0) 反对(0) 阳阳享受阳光~ | 园豆:202 (菜鸟二级) | 2018-03-28 11:45

@阳阳享受阳光~: 我也做过微信 但是微信是不需要用代码登录的 先手动登录进去 然后再进行操作

支持(0) 反对(0) ycyzharry | 园豆:25683 (高人七级) | 2018-03-28 11:48

@ycyzharry: 好的 我试试。谢谢您了!

支持(0) 反对(0) 阳阳享受阳光~ | 园豆:202 (菜鸟二级) | 2018-03-28 11:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册