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)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM