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