admin管理员组文章数量:1384326
I am trying to use the explicit locator strategy in the Selenium Robot library to find an element:
Click Element xpath://*[@id="sidebar-nav"]
I can locate the element using this xpath on the web console, but when I run my Robot test I'm getting an element not found error. I haven't been able to locate it using css either. What am I doing wrong?
I am trying to use the explicit locator strategy in the Selenium Robot library to find an element:
Click Element xpath://*[@id="sidebar-nav"]
I can locate the element using this xpath on the web console, but when I run my Robot test I'm getting an element not found error. I haven't been able to locate it using css either. What am I doing wrong?
Share Improve this question edited Mar 18 at 19:47 JeffC 26k5 gold badges34 silver badges55 bronze badges asked Mar 18 at 18:24 JatJat 111 silver badge4 bronze badges 7- These type of issue usually occurs when an ID or class is added dynamically after a delay, making it unavailable in the DOM when Selenium initially checks for it. Did you check if this is the case? – Jyoti Ahluwalia Commented Mar 18 at 18:39
- 1 It's usually one of two things: 1. You need to wait for the element, 2. The element is in an IFRAME or shadow-dom. – JeffC Commented Mar 18 at 18:42
- @JyotiAhluwalia that doesn't seem to be the issue but I hadn't checked for it before you mentioned it, so thank you – Jat Commented Mar 18 at 19:31
- @JeffC I know it's not an IFRAME or shadow-dom, so I did try extending the wait time longer to 8s, which worked. When I run the test manually the element becomes clickable in -3s, so now I need to figure out why it's so slow which is a whole other issue. Thanks! – Jat Commented Mar 18 at 19:37
- 1 @JeffC can't vote yet but will once I can – Jat Commented Mar 19 at 14:28
1 Answer
Reset to default 1It's usually one of two things:
- You need to wait for the element
- The element is in an IFRAME or shadow-dom
If you need to add waits, use things like
Wait Until Element Is Visible
Wait Until Element Is Not Visible
Wait Until Page Contains Element
Wait Until Page Does Not Contain Element
See the docs, https://github/robotframework/HowToWriteGoodTestCases/blob/master/HowToWriteGoodTestCases.rst#avoid-sleeping
版权声明:本文标题:robotframework - Why am I getting an element not found error when my xpath locator is correct? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744497230a2609103.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论