return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>robotframework - Why am I getting an element not found error when my xpath locator is correct? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

robotframework - Why am I getting an element not found error when my xpath locator is correct? - Stack Overflow

programmeradmin1浏览0评论

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
 |  Show 2 more comments

1 Answer 1

Reset to default 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

If you need to add waits, use things like

  1. Wait Until Element Is Visible
  2. Wait Until Element Is Not Visible
  3. Wait Until Page Contains Element
  4. Wait Until Page Does Not Contain Element

See the docs, https://github/robotframework/HowToWriteGoodTestCases/blob/master/HowToWriteGoodTestCases.rst#avoid-sleeping

发布评论

评论列表(0)

  1. 暂无评论