Selenium报错:StaleElementReferenceException
一个学生在操作页面跳转时遇到一个Selenium报错, 如下图所示:
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document ...
出错原因为: Selenium只能操作当前打开页面中的可见元素,当页面跳转, 前进, 后退, 或刷新后, 之前定位到的元素要重新定位才能使用.
可以尝试运行以下脚本, 查看报错信息:
from selenium import webdriver
dr = webdriver.Chrome()
dr.get('http://www.baidu.com')
search = dr.find_element_by_id("kw")
dr.refresh()
# search.send_keys("刷新后输入") # 报错: StaleElementReferenceException
dr.get("http://www.hao123.com")
# search.send_keys("刷新后输入") # 报错: StaleElementReferenceException
dr.back()
search.send_keys("刷新后输入") # 报错: StaleElementReferenceException
Selenium报错:StaleElementReferenceException的更多相关文章
- 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist
解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...
- selenium报错以及各解决方法
1.driver.findElement(By.name("wd")).sendKeys("selenium"); 报错:The method sendKeys ...
- selenium报错汇总
selenium报错汇总 报错:[error] Could not connect to Selenium Server. Have you started the Selenium Server y ...
- ie11 selenium 报错org.openqa.selenium.NoSuchWindowException: Unable to get browser 处理方法
selenium + ie11运行报错 org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The s ...
- python selenium 报错unknown error: cannot focus element 解决办法
登录框由于js限制,定位到元素后无法sendkey ,sendky报错如下: selenium.common.exceptions.WebDriverException: Message: unkno ...
- python执行selenium报错
python + unittest + HTMLTestRunner 执行suite用例报错 Traceback (most recent call last): File "C:/ws/S ...
- Jenkins执行selenium报错unknown error: cannot find Chrome binary
问题描述:在Pycharm中执行selenium测试用例,可以正常运行, 集成在Jenkins中,构建时,发现构建成功,但是查看Console Output,报错:unknown error: can ...
- windows下使用selenium报错selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH
问题 :执行程序代码报错: WebDriverException:Message:'geckodriver'executable needs to be in Path 或者 selenium.com ...
- windows使用pip安装selenium报错问题
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 7: ordinal not in range(128) 这是 ...
随机推荐
- k8s-traefik默认80端口
vim traefik.yaml kind: Deployment apiVersion: extensions/v1beta1 metadata: name: traefik-ingress-con ...
- [Tarjan系列] 无向图e-DCC和v-DCC的缩点
上一篇讲了如何应用Tarjan算法求出e-DCC和v-DCC. 那么这一篇就是e-DCC和v-DCC的应用之一:缩点. 先讲e-DCC的缩点. 我们把每一个e-DCC都看成一个节点,把所有桥边(x,y ...
- hdu 6047
题解:先对b排序,用一个数组预处理a,记录当前位置之后到n的最大值,然后在用一个变量维护新增变量的最大值,用的时候和前面的数组的最大值做一个比较就ok. AC代码: #include <cstd ...
- 在javascript对象内搜索,貌似是一个新鲜的话题。
为啥 也不为啥,因为没找到. 用途 也没啥用途,比如,在电影网站找到链接,在小说网站找到链接.二货同事写的复杂对象.等等吧.反正要搜索就对了. 目标 在对象内,无论多少层,找到关键字. 关键字可能的位 ...
- MySql学习- 存储引擎简介
mysql可以将数据以不同的技术存储在文件(内存)中,这种技术就称为存储引擎. 每一种存储引擎使用不同的存储机制.索引技巧.锁定水平,最终提供广泛且不同的功能. MySQL支持的存储引擎: MyISA ...
- 在Windows中 , 如何用leakdiag “自动”检测内存泄露 (自动记录日志)
一.基本用法 在LeakDiag中选择aaa.exe 然后选择Windows Heap Allocator来跟踪heap的使用,按start开始,等一会按log,然后再stop 会在c:\leakdi ...
- 安卓SharedPreferences类的使用
package com.lidaochen.phonecall; import android.content.Intent; import android.content.SharedPrefere ...
- MySQL间隙锁问题
间隙锁(Gap Lock):锁加在不存在的空闲空间,可以是两个索引记录之间,也可能是第一个索引记录之前或最后一个索引之后的空间. 最近用户反馈说系统老是出现insert时,等待超时了,最后发现是ins ...
- mock.js学习之路一(Vue中使用)
1.安装mockjs 2.配置mockjs在开发环境中启用,生产环境中禁用 3.创建mock文件夹,以及mock数据文件 4.在main.js中引入与否 5.页面获取数据 testMock(){ th ...
- 交换机配置-----monitor session
目录 交换机配置-----monitor 1.前言 2.monitor session的作用 3.配置命令 4.使用 交换机配置-----monitor 1.前言 本文章适用于Dell Network ...