今天在调试脚本的过程中,同样的脚本,有的时候会出现元素定位不到的情况,报错信息如下:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Timed out after 15558ms waiting for the root AccessibilityNodeInfo in the active window. Make sure the active window is not constantly hogging the main UI thread (e.g. the application is being idle long enough), so the accessibility manager could do its work\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'\nSystem info: host: 'LY202102250052', ip: '172.26.131.85', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.1'\nDriver info: io.appium.java_client.android.AndroidDriver\nCapabilities {adbExecTimeout: 7200000, automationName: UIAutomator2, browserName: , chromedriverChromeMappingFile: webview/version.json, chromedriverExecutableDir: webview, databaseEnabled: false, desired: {adbExecTimeout: 7200000, automationName: UIAutomator2, browserName: , chromedriverChromeMappingFile: webview/version.json, chromedriverExecutableDir: webview, disableSuppressAccessibilityService: true, goog:chromeOptions: {androidProcess: com.tencent.mm:tools, args: [], extensions: []}, newCommandTimeout: 7200, noReset: true, platformName: android, recreateChromeDriverSessions: true, skipLogcatCapture: true, systemPort: 20418, udid: WTK7N16A10002895, uiautomator2ServerInstallTimeout: 600000}, deviceApiLevel: 26, deviceManufacturer: HUAWEI, deviceModel: FRD-AL00, deviceName: WTK7N16A10002895, deviceScreenDensity: 480, deviceScreenSize: 1080x1920, deviceUDID: WTK7N16A10002895, disableSuppressAccessibilityService: true, goog:chromeOptions: {androidProcess: com.tencent.mm:tools, args: [], extensions: []}, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 7200, noReset: true, pixelRatio: 3, platform: LINUX, platformName: ANDROID, platformVersion: 8.0.0, recreateChromeDriverSessions: true, skipLogcatCapture: true, statBarHeight: 72, systemPort: 20418, takesScreenshot: true, udid: WTK7N16A10002895, uiautomator2ServerInstallTimeout: 600000, viewportRect: {height: 1720, left: 0, top: 72, width: 1080}, warnings: {}, webStorageEnabled: false}\nSession ID: 507d473c-9ca6-4e9c-a056-1c2266ebc855\n*** Element info: {Using=id, value=com.lanyou.base.ilink:id/exit_tv}","time":"17:29:38","rid":0,"udId":"WTK7N16A10002895","status":3,"cid":0}
这个元素有的时候可以定位到,有的时候定位不到,元素定位的方式没有改变,一直使用的是id定位,在自己的脚本中使用的时候是一直可以定位到的,在 sonic 这边使用的时候,发现有的时候会出现定位不到的情况。
出错比较频繁的场景有:多次切换控件元素与UI自动化页面以及多次调试执行该条用例这两种情况时会比较容易出现,另外多次切换控件元素与UI自动化页面时也容易出现获取控件元素失败的情况。