我正在尝试定位9-11阴影根内部的元素。常规定位器(例如xpath,css,id)无法定位。我可以使用Java中的JavascriptExecutor()来定位元素。但是这个过程非常繁琐。我也用打字稿在量角器框架上工作。我需要找到突出显示的元素。
非常感谢您的帮助![在此处输入图片描述] [1]
我建议使用'by.react'组件,而不是使用自定义的javascript来查找元素,这使反应选择非常容易。
https://www.npmjs.com/package/protractor-react-selector
// with only component. If you don't provide any root element, it assume that root is set to '#root'
const myElement = element(by.react('MyComponent'));
// to fetch all elements matched with component, props and state, you can use protractor native 'all' method
const myElement = element.all(by.react('MyComponent'));
让我知道这是否对您有帮助:)