selenium报错:Message: stale element reference: element is not attached to the page document
在使用selenium时,报了一个错误

报错的原因:
所引用的元素已过时,不再依附于当前页面。通常情况下,这是因为页面进行了刷新或跳转
解决方法:
重新定位元素
代码示例:
# 旧代码(报错)
lists = self.root.find_elements_by_xpath('/html/body/table[4]/tbody/tr[2]/td/a')
for i in lists:
self.root.get(i.get_attribute(''href))
# 新代码(解决方法)
lists = self.root.find_elements_by_xpath('/html/body/table[4]/tbody/tr[2]/td/a')
for j in range(len(lists)):
self.root.find_elements_by_xpath('/html/body/table[4]/tbody/tr[2]/td/a')[j].click()
selenium报错:Message: stale element reference: element is not attached to the page document的更多相关文章
- appium报错Message: Cannot set the element to ‘XXXX’. Did you interact with the correct element?
appium+python+android 在定位到模块输入内容的时候遇到了一个问题 send_keys报错 appium报错Message: Cannot set the element to 'X ...
- python selenium 报错unknown error: cannot focus element 解决办法
登录框由于js限制,定位到元素后无法sendkey ,sendky报错如下: selenium.common.exceptions.WebDriverException: Message: unkno ...
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = ...
- 关于报错stale element reference: element is not attached to the page document处理
1.现象 在执行脚本时,有时候引用一些元素对象会抛出如下异常 org.openqa.selenium.StaleElementReferenceException: stale element ref ...
- 报错stale element reference: element is not attached to the page document结局方案
今天在调试脚本时,遇到如下报错: org.openqa.selenium.StaleElementReferenceException: stale element reference: elemen ...
- stale element reference: element is not attached to the page document 异常
在执行脚本时,有时候引用一些元素对象会抛出如下异常 org.openqa.selenium.StaleElementReferenceException: stale element referenc ...
- Selenium报错:StaleElementReferenceException
一个学生在操作页面跳转时遇到一个Selenium报错, 如下图所示: StaleElementReferenceException: Message: stale element reference: ...
- selenium报错以及各解决方法
1.driver.findElement(By.name("wd")).sendKeys("selenium"); 报错:The method sendKeys ...
- 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist
解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...
- selenium报错汇总
selenium报错汇总 报错:[error] Could not connect to Selenium Server. Have you started the Selenium Server y ...
随机推荐
- 常用 Maven 插件介绍
我们都知道Maven本质上是一个插件框架,它的核心并不执行任何具体的构建任务,所有这些任务都交给插件来完成,例如编译源代码是由maven- compiler-plugin完成的.进一步说,每个任务对应 ...
- C++特殊类的设计与单例模式
#pragma once // 1. 设计一个不能被拷贝的类/* 解析:拷贝只会放生在两个场景中:拷贝构造函数以及赋值运算符重载,因此想要让一个类禁止拷贝, 只需让该类不能调用拷贝构造函数以及赋值运算 ...
- [vbs] 定时关闭进程代码
Dim bag,pipe do Set bag=GetObject("WinMgmts:") Set pipe=bag.execquery("select * from ...
- Java 常用类 String的使用
1 package com.bytezero.stringclass; 2 3 import com.sun.tools.javac.Main; 4 import jdk.jfr.StackTrace ...
- 字典嵌套列表 与 列表嵌套字典 导出为csv 的方法
字典嵌套列表 导出csv {'rank': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '1 ...
- XAF Blazor 中使用 Blazor 组件
前言 文章的标题是不是感觉有点奇怪,但实际我们在XAFBlazor中使用Blazor组件是很繁琐的,我们需要将Blazor组件封装成属性编辑器(PropertyEditor),再用非持久化对象(Non ...
- Zabbix自动发现:python-json模块应用介绍
一.JSON模块介绍 json模块是python内置的库,其主要功能是将序列化数据从文件里读取出来或者存入文件.该模块有四个方法:dump().load().dumps().loads(),其中dum ...
- idea branch 分支比较 | git 查看分支命令 `git branch -vv`
git 查看分支命令 git branch -vv
- 候捷-C++程序设计(Ⅱ)兼谈对象模型
目录 笔记参考 学习目标 转换函数与explicit pointer-like classes function-like classes 模板template 模板特化与偏特化 模板模板参数 引用( ...
- 修改校准debain/manjaro的时间时钟
一次重启后发现时间竟然从上午变成了晚上!要问,我是怎么发现在的我就是发现上午的时候我的屏幕夜灯突然出现了 使用命令 sudo rm -f /etc/localtime删除本地时间文件 sudo cp ...