使用Appium 调试元素定位,使用xpath的轴定位,会报错:
An unknown server-side error occurred while processing the command. Original error: java.util.ArrayList$ListItr cannot be cast to org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType. Try changing the 'enforceXPath1' driver setting to 'true' in order to workaround the problem.
这是因为对于更复杂的定位器来说,默认的XPath2可能会出现一些问题,所以可以通过强制使用XPath1来解决,参考 https://github.com/appium/appium-uiautomator2-driver
这个 enforceXPath1 在 Inspector 中需要通过命令设置,在下图的位置填入:
{"enforceXPath1": true}
执行后可以通过getSettings验证是否修改成功
再次尝试通过轴定位元素,可以成功定位