appium 啟動雙機驅動,為什麼只有最後一個驅動才能執行正常定位操作?

jurryfu發表於2020-05-30

業務背景:需要兩部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);//如果安裝就不要安裝了

相關文章