selenium2.0报错:stale element reference: element is not attached to the page document的解决办法
来源:互联网 发布:it培训机构排名 编辑:程序博客网 时间:2024/05/20 12:50
使用selenium webdriver编写自动化脚本时,遇到异常报错为:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
经各方查证,大概意思是说:意思就是Element已经过时,没有和当前页面进行绑定,主要是页面刷新或者跳转引起的,需要重新获取一次元素。
修改之前代码如下:
action.find_element_by_css_selector("div[node-id='93']").click() time.sleep(2) action.switch_to.frame("93") sreach_code=snapshot+date time.sleep(2) action.find_element_by_xpath("//*[@id='container']/div/ul/li[2]/a/span").click() time.sleep(2) list_data=action.find_elements_by_css_selector("#tab_todo>div>div.row.approvals>a") for ld in list_data: if snapshot in str(ld.text.encode("utf-8")): if date in str(ld.text.encode("utf-8")): ld.click()
修改之后代码如下:
action.find_element_by_css_selector("div[node-id='93']").click() time.sleep(2) action.switch_to.frame("93") sreach_code=snapshot+date time.sleep(2) action.find_element_by_xpath("//*[@id='container']/div/ul/li[2]/a/span").click() time.sleep(2) list_data=action.find_elements_by_css_selector("#tab_todo>div>div.row.approvals>a") for ld in list_data: if snapshot in str(ld.text.encode("utf-8")): if date in str(ld.text.encode("utf-8")): subscript=list_data.index(ld) list_data[subscript].click()
没有再次报错的原因不明,仅此记录,待后续查证。
参考资料:
WebUI自动化测试问题总结—基于Dagger http://zhangzhenzhen2009.blog.163.com/blog/static/187039247201481871342610/
0 0
- selenium2.0报错:stale element reference: element is not attached to the page document的解决办法
- stale element reference: element is not attached to the page document
- Selenium element is not attached to the page document
- Stale Element Reference Exception
- IE8报错:Unable to modify the parent container element before the child element is closed
- The prefix "mvc" for element "mvc:annotation-driven" is not bound 报错的解决方法
- source not found-Note:This element has not attached解决办法
- Note: This element has no attached source and Javadoc could not be found in the attached Javadoc解决办法
- webdriver 报错:Element is not clickable at point (993, 61). Other element would receive the click
- webdriver 报错:Element is not clickable at point (993, 61). Other element would receive the click
- 解决Selenium报错:Element is not clickable at point (x, y). Other element would receive the click
- Spring配置文件标签报错:The prefix "XXX" for element "XXX:XXX" is not bound.
- Spring配置文件标签报错:The prefix "XXX" for element "XXX:XXX" is not bound. .
- 报错:The prefix "context" for element "context:annotation-config" is not bound.
- 解决selenium报错Element is not clickable at point...
- xml报错The markup in the document following the root element must be well-formed的处理
- webform报错:The HTTP verb POST used to access path * is not allow的解决办法
- WP7 报 Element is already the child of another element. [Line: 0 Position: 0]
- asp.net三层架构连接Oracle 11g详解
- Hibernate(二)
- 开个博客瞧一瞧
- Android简易实战教程--第十三话《短信备份和还原~三》
- #107 Word Break
- selenium2.0报错:stale element reference: element is not attached to the page document的解决办法
- Hdu 4309Seikimatsu Occult Tonneru【最大流Dinic+暴力枚举Dfs+建图】人生难免磕磕碰碰
- HDU 2089 数位DP入门
- 数学公式 —— 向量
- .club域名转移注册商失败的事件(图文)
- 制作一个Linux下炫酷吊炸天的log输出工具
- ruby升级
- Mishka and trip(CF 703B)
- 2016暑期集训4——数据结构(知识点,模板,简单题题解)