Appium appium 启动双机驱动,为什么只有最后一个驱动才能执行正常定位操作?

jurryfu · 2020年05月30日 · 1156 次阅读

业务背景:需要两部 ios 手机同时启动参与测试
代码实现:如下启动代码调用两次,deviceName 分别指定两部手机。

启动后分别用 IOSDriver iosDriver1 以及 IOSDriver iosDriver2 变量引用
启动服务:两个驱动对应的服务启动命令分别为:
appium -a 127.0.0.1 -p 5000 -bp 5100 --session-override &
appium -a 127.0.0.1 -p 5001 -bp 5101 --session-override &
问题描述:当执行 iosDriver2.findElement(MobileBy.AccessibilityId("出品")).click(); 可以正常执行
但是执行 iosDriver1.findElement(MobileBy.AccessibilityId("老司机出品")).click(); 就会报找不到对象的错误
错误信息:
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'fujiaxideMacBook-Pro.local', ip: '192.168.6.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_91'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/fujiaxi/Desktop/ywf.app, automationName: XCUITest, browserName: , databaseEnabled: false, deviceName: iPhone 8 Plus, fullReset: false, ignoreUnimportantViews: true, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 99999, noReset: true, platform: MAC, platformName: IOS, platformVersion: 13.3, resetKeyboard: true, sessionOverride: true, takesScreenshot: true, udid: A8D89A86-6824-42F6-8D4B-6CC..., unicodeKeyboard: true, webStorageEnabled: false}
Session ID: fdcf6a58-f347-4934-b950-477569768b88

启动代码:

  DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
                desiredCapabilities.setCapability("platformName", Platform.IOS);
                desiredCapabilities.setCapability("platformVersion", map.get("version"));
                desiredCapabilities.setCapability(MobileCapabilityType.APP, app);
//                desiredCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.SAFARI);
                desiredCapabilities.setCapability("deviceName", map.get("name"));
                desiredCapabilities.setCapability("automationName", "XCUITest");
                desiredCapabilities.setCapability("noReset", true);//如果安装就不要安装了

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册