在使用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的更多相关文章

  1. 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 ...

  2. python selenium 报错unknown error: cannot focus element 解决办法

    登录框由于js限制,定位到元素后无法sendkey ,sendky报错如下: selenium.common.exceptions.WebDriverException: Message: unkno ...

  3. selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

    抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = ...

  4. 关于报错stale element reference: element is not attached to the page document处理

    1.现象 在执行脚本时,有时候引用一些元素对象会抛出如下异常 org.openqa.selenium.StaleElementReferenceException: stale element ref ...

  5. 报错stale element reference: element is not attached to the page document结局方案

    今天在调试脚本时,遇到如下报错: org.openqa.selenium.StaleElementReferenceException: stale element reference: elemen ...

  6. stale element reference: element is not attached to the page document 异常

    在执行脚本时,有时候引用一些元素对象会抛出如下异常 org.openqa.selenium.StaleElementReferenceException: stale element referenc ...

  7. Selenium报错:StaleElementReferenceException

    一个学生在操作页面跳转时遇到一个Selenium报错, 如下图所示: StaleElementReferenceException: Message: stale element reference: ...

  8. selenium报错以及各解决方法

    1.driver.findElement(By.name("wd")).sendKeys("selenium"); 报错:The method sendKeys ...

  9. 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist

    解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...

  10. selenium报错汇总

    selenium报错汇总 报错:[error] Could not connect to Selenium Server. Have you started the Selenium Server y ...

随机推荐

  1. 阿尔萨斯(Arthas)入门

    目录 简介 Arthas(阿尔萨斯) 能为你做什么 安装 快速安装 全量安装 卸载 使用 启动arthas 查看dashboard 通过thread命令来获取到arthas-demo进程的Main C ...

  2. 【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-AzContext' is not recognized as the name

    问题描述 Azure Web Job执行Powershell脚本报错 Select-AzContext : The term 'Select-AzContext' is not recognized ...

  3. 【Azure 应用服务】 部署到App Service for Linux 服务的Docker 镜像,如何配置监听端口呢?

    问题描述 根据以下DockerFile文件,创建了一个ASP.NET Core的 helloworld 镜像,通过监听3721端口来接受请求. # 1. 指定编译和发布应用的镜像 FROM mcr.m ...

  4. Postman/Jmeter工具实现接口测试,为什么还要用代码来实现接口自动化测试?

    这种工具包括一些开源框架最大缺点就是不够灵活,如果是单接口的测试还行,但是有的项目接口比较庞大和负责,这种情况下就不大适用工具(工具适用于小型项目,代码适用于中大型项目) 主要有以下几个原因: 1敏捷 ...

  5. 15. JVM垃圾回收器详解

    1. 垃圾回收器的分类 和 GC性能指标 垃圾收集器没有在规范中进行过多的规定,可以由不同的厂商.不同版本的JVM来实现. 由于JDK的版本处于高速迭代过程中,因此Java发展至今已经衍生了众多的GC ...

  6. GB 2312字符集:中文编码的基石

    一.GB 2312字符集的背景 GB 2312字符集是中国国家标准委员会于1980年发布的一种中文字符集,是中国大陆最早的中文字符集之一.GB 2312字符集的发布填补了中国大陆中文编码的空白,为中文 ...

  7. vue 的属性展开 props v-bind 记得带key

    <el-table-column v-for="column in columns" :key="column.prop" v-bind="co ...

  8. Android Studio安装插件重启插件消失

    问题 安装插件后,已经提示让重启IDE,但是重启后发现插件是安装失败了 解决方法 原因是自己改了配置,如果下载的插件是jar包,则可以安装,如果是zip压缩文件的插件,则是要我们手动解压一下 我上面的 ...

  9. KTL 一个支持C++14编辑公式的K线技术工具平台

    K,K线,Candle蜡烛图. T,技术分析,工具平台 L,公式Language语言使用c++14,Lite小巧简易. 项目仓库:https://github.com/bbqz007/KTL 国内仓库 ...

  10. thttpd 2.27(最新)移植指南(官方安装脚本好多坑,我只想说)

    PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明   本文作为本人csdn blog的主站的备份.(Bl ...