我正在尝试定位9-11阴影根中的元素。xpath、css、id等常规定位器无法定位。我能够在java中使用JavascriptExecutor()来定位元素。但是这个过程非常单调乏味。我还在使用typescript的量角器框架上工作。我需要找到突出显示的元素。
任何帮助都是非常感谢的!
发布于 2020-04-30 16:27:10
我推荐使用'by.react‘组件,而不是使用自定义的javascript来查找元素,这使得react的选择变得非常容易。
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'));
如果这对您有帮助,请让我知道:)
https://stackoverflow.com/questions/61468832
复制相似问题