web自动化测试——问题1:selenium.common.exceptions.NoSuchElementException:Message: Unable to locate element:{“method”:“xpath”,“selector”:"/html/body/div[2]/div[3]/div/div[3]/div[1]/div[2]"}

  1. 报错原因
    经过网上各种搜索大致明白是什么原因导致此报错:当启动脚本后,从页面A打开页面B后,窗口句柄(焦点)依旧停留在主页面A,所以无法定位页面B的元素。

  2. 亲测过两种方法
    方法一:search_window = driver.current_window_handle
    运行成功,但不是每次都能成,在打开另外一个网页时使用该方法,没有成功。
    web自动化测试——问题1:selenium.common.exceptions.NoSuchElementException:Message: Unable to locate element:{"
    方法二:driver.switch_to.window(driver.window_handles[1])
    使用该方法出现了一个新的报错IndexError: list index out of range,还没找到方法解决
    web自动化测试——问题1:selenium.common.exceptions.NoSuchElementException:Message: Unable to locate element:{"

相关文章:

  • 2021-12-29
  • 2022-02-08
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2021-06-04
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案