Appium中【MJSONWP】错误

  • Appium自动化测试错误提示An element could not be located on the page using the given search parameters
    • 错误截图
    • 代码
    • 其他问题

Appium自动化测试错误提示An element could not be located on the page using the given search parameters

最近在学习自动化测试由Python语言转向Java语言,前者测试同一APP可流畅运行,后者可启动APP,但一到相关定位时就没反应,Appium日志显示错误信息,Eclipse控制台报错,不知道是哪里出了问题希望得当帮助,谢谢各位!

错误截图

Eclipse错误截图:
APP启动界面截图:

Appium日志截图:

项目结构截图:

测试代码截图:

代码

测试代码:

package qichezhijia;import static org.junit.Assert.assertEquals;import java.net.URL;
import java.util.concurrent.TimeUnit;import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;public class QIche {private AndroidDriver  driver;private WebDriverWait wait;@Beforepublic void setup() throws Exception {DesiredCapabilities cap = new DesiredCapabilities();cap.setCapability("browserName", "");   //这里不需要设置浏览器,只有H5模式才设置为"chrome"或系统原始浏览器"browser" cap.setCapability("platformName", "Android"); //指定测试平台//雷电安卓模拟器cap.setCapability("deviceName", "emulator-5554"); //指定测试机的ID,通过adb命令`adb devices`获取cap.setCapability("platformVersion", "5.1"); //安卓真机//cap.setCapability("deviceName", "68U5T17A08002290"); //指定测试机的ID,通过adb命令`adb devices`获取//cap.setCapability("platformVersion", "7.0"); //将上面获取到的包名和Activity名设置为值cap.setCapability("appPackage", "com.cubic.autohome");cap.setCapability("appActivity", "com.cubic.autohome.LogoActivity");//A new session could not be created的解决方法cap.setCapability("appWaitActivity","com.cubic.autohome.LogoActivity");//每次启动时覆盖session,否则第二次后运行会报错不能新建sessioncap.setCapability("sessionOverride", "true");//设置app每次运行不被重新初始化cap.setCapability("noReset","true");cap.setCapability("fullReset","false"); //设置使用unicode键盘,支持输入中文和特殊字符cap.setCapability("unicodeKeyboard", "true");//设置用例执行完成后重置键盘cap.setCapability("resetKeyboard", "true");cap.setCapability("noSign", "true");//使用UiAutomator2框架便于获取toast信息cap.setCapability("automationName", "UiAutomator2");driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);wait = new WebDriverWait(driver, 15); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);//隐式等待,最大超时10秒}@Testpublic void TestBig() throws InterruptedException{driver.findElementByXPath("//android.widget.TextView[@text='下次再说']").click();driver.findElementById("com.autohome.main.article:id/iv_search").click();Thread.sleep(1000);driver.findElementById("com.autohome.plugin.search:id/fragment_search_keyword_autocompleteview").sendKeys("大黄蜂");}@Afterpublic void tearDown() throws Exception {Thread.sleep(1000);   //暂停1秒driver.quit();//关闭}}

控制台错误代码:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.cubic.autohome' application. Original error: 'com.cubic.autohome.LogoActivity' or 'com.cubic.autohome.com.cubic.autohome.LogoActivity' never started (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.17 seconds
Build info: version: '3.6.0', revision: '6fbf3ec777', time: '2017-09-27T16:15:26.402Z'
System info: host: 'KIPKANG', ip: '192.168.100.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_251'
Driver info: driver.version: AndroidDriverat 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:214)at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359)at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)at java.util.stream.AbstractPipeline.copyInto(Unknown Source)at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)at java.util.stream.AbstractPipeline.evaluate(Unknown Source)at java.util.stream.ReferencePipeline.findFirst(Unknown Source)at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362)at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)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.startSession(RemoteWebDriver.java:217)at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:83)at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:93)at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:72)at qichezhijia.QIche.setup(QIche.java:55)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)java.lang.NullPointerExceptionat qichezhijia.QIche.tearDown(QIche.java:80)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

Appium日志代码:

Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8204
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward --remove tcp\:8204'
[BaseDriver] Event 'newSessionStarted' logged at 1593943854948 (18:10:54 GMT+0800 (中国标准时间))
[MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.cubic.autohome' application. Original error: 'com.cubic.autohome.LogoActivity' or 'com.cubic.autohome.com.cubic.autohome.LogoActivity' never started
[MJSONWP]     at ADB.callee$0$0$ (C:\Users\清濑灰二\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:125:11)
[MJSONWP]     at tryCatch (C:\Users\清濑灰二\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\清濑灰二\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\清濑灰二\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[MJSONWP]     at GeneratorFunctionPrototype.invoke (C:\Users\清濑灰二\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[MJSONWP]     at
[HTTP] <-- POST /wd/hub/session 500 61106 ms - 307
[HTTP]

其他问题

使用的是老师给的APpiumDemo的java模板,在运行单机计算器时能正常运行,但换一下APP就出错了
-测试截图:
APP运行用例截图:

日志截图:

测试用例代码截图:

-照葫芦画瓢都能出错,实在是找不到哪里出了问题,孩子太难了,救救孩子吧。

An element could not be located on the page using the given search parameters.相关推荐

  1. Appium工作日记:Message: An element could not be located on the page using the given search parameters.

    程序运行2个月都没问题,突然报错,这突如其来的血压飙升` 报错代码如下: NoSuchElementException Traceback (most recent call last) <ip ...

  2. Python +appium 报错:NoSuchElementException: Message: An element could not be located on the page using

    报错代码: NoSuchElementException: Message: An element could not be located on the page using the given s ...

  3. python uiautomator2 toast_appium+uiautomator2定位toast元素失败,求解决方案

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 appium1.15 Python3.7 安卓设备:5.1.1 定位时报错,找不到元素 配置:desired_caps = {} desired_caps ...

  4. Selenium1 Selenium2 WebDriver

    内容摘要: Selenium 1 原理 WebDriver WebDriver 组件 WebDriver 协议 Remote End 处理流程 Commands & Endpoints &am ...

  5. appium java 点击事件_java – 无法使用Appium在Android中的权限对话框中单击“允许”按钮...

    我无法使用Appium Java在 Android的权限对话框中点击"拒绝"或"允许"按钮.在点击这些按钮之前,是否需要添加任何功能? 以下是代码: Desir ...

  6. 从0到1搭建移动App功能自动化测试平台(2):操作iOS应用的控件

    转载:http://debugtalk.com/post/build-app-automated-test-platform-from-0-to-1-Appium-interrogate-iOS-UI ...

  7. android chrome无法运行,Android 测试 Chrome 浏览器能正常启动 Chrome 浏览器,但是不能进行操作,求大神!!...

    chrome 能在 android 手机上启动 但是就是不能打开网站.或者操作 chrome 里面的按钮.求大神帮忙看下 ,万分感谢. 代码 : private AppiumDriver ab =nu ...

  8. python怎么通过手机号定位_6.1 python+appium元素定位方式(登录app)

    1.0.0 :常见的十种元素定位方式 1.driver.find_element_by_id() #id定位2.driver.find_element_by_name() #name定位(已经凉了,不 ...

  9. 网站源码抓取css.html.jss,javascript-使用WWW :: Mechanize :: Chrome使用Chrome / Chromium从服务器获取“原始” jss和css代码...

    我正在尝试使用WWW :: Mechanize :: Chrome浏览器下载css / js文件.是的,还有其他获取文件的方法.但是我的要求是使用WWW :: Mechanize :: Chrome来 ...

最新文章

  1. redissession有容量上限吗_空气炸锅值得买吗?
  2. insert size|single-read|Paired-end|Mate-pair
  3. 怎么查看自己电脑的配置_怎么查看自己网卡是千兆网卡还是百兆网卡
  4. mysql某个字段改为非unique
  5. 关于清晰讲解linux正则表达式的博文分享
  6. 改造独立部署(SCD)模式下.NET Core应用程序 dotnet的exe文件启动过程
  7. 我们相信加密! 教程
  8. Signals Slots(Qt5)
  9. 3842开关电源完整原理图_8大常见开关电源电路分析,让你项目设计更轻松!
  10. 自制胎教音乐---太阳当头照
  11. 滴滴辞退2000人启示:牛逼的人,都有自己的铁饭碗
  12. 关于flashdevelop测试flex项目时trace不出的解决方法
  13. 常用的linux连接工具
  14. 【推理加速】博客翻译:利用融合conv和bn的方法加速模型
  15. TabLayout的Indicator自定义宽度
  16. STM32与串口屏交互(USART HMI)
  17. 计算机图形学必备的数学知识
  18. jquery slideToggle() 效果
  19. GPS从入门到放弃(三)、GPS坐标系
  20. 碳足迹分析软件市场现状研究分析报告-

热门文章

  1. 【Golang】golang开发微信公众号网页授权功能
  2. 湖北工业大学校园网自动认证功能
  3. 微信小程序实现vtt视频字幕
  4. SSL安全证书过期的原因及解决方法
  5. 记录ssl证书过期,更新证书的过程
  6. 【Datawhale组队学习】机器学习数学基础 - 一元函数微分学的几何应用【Task 04】
  7. 在excel中如何筛选重复数据_Excel中12招筛选使用大全,小白也能秒变高手
  8. 趣图:Python 程序员转 Java
  9. siamfc-pytorch代码讲解(三):demotrack
  10. python相关性分析模型,相关性分析原理及Python实战