python+selenium自动化测试同一个浏览器如何切换到另一个页面

 

 某个操作点击之后形成第二个标签就可以进行下方的代码的书写

index = self.driver.current_window_handle


handles = self.driver.window_handles
current= None


for handle in handles:
if handle != index:
current= handle
self.driver.switch_to.window(current)
time.sleep(3)
#在另一个页面需要进行的操作

.......
self.driver.close()

#切换回到原来的页面
self.driver.switch_to.window(index)

相关文章:

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