JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

解决Python+selenium切换作用域时报错'WebDriver' object has no attribute 'switch_to_window'

发布时间 2023-03-22 21:13:11作者: 一个名

一、问题描述

selenium切换新网页作用域时,报错:'WebDriver' object has no attribute 'switch_to_window'

问题代码:

driver.switch_to_window(driver.window_handles[-1]) 

二、问题解决

selenium的版本问题,将switch_to_window()换成switch_to.window()即可

driver.switch_to.window(driver.window_handles[-1])   #把driver切换到最新弹出来的窗口

 

    本栏目推荐文章
  • webdriver.Chrome New API
  • Selenium Grid4.0 - 多台计算机上并行运行
  • 【五期李伟平】CCF-A(AAAI'21)Game of Gradients: Mitigating Irrelevant Clients in Federated Learning
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • Python中出现"No module named 'requests'"的图文解决办法
  • ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password'
  • mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; ERROR 1410 (42000): You are not allowed to create a user with GRANT
  • selenium加载驱动的两种方式
  • mybatis提示com.microsoft.sqlserver.jdbc.SQLServerException: 列名 'xxxx' 无效。
  • Flutter 项目运行到ios模拟器报错 : Error (Xcode): SDK does not contain 'libarclite'
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们