[英]Selenium Python After pressing the button,a new window opens,I can't press the keys there
I am new to python https://prnt.sc/26nlk3q I press the button on the site, then this window appears in which you need to click to confirm I tried this我是 python https://prnt.sc/26nlk3q的新手,我按下网站上的按钮,然后这个 window 出现在其中你需要点击确认我试过了
driver.switch_to.window(driver.window_handles[-1])
And This和这个
alert = browser.switch_to.alert
alert.accept()
but its not working for me但它不适合我
I can show you how it looks in the browser, if necessary如有必要,我可以向您展示它在浏览器中的外观
This window has a separate html code, I do not understand how to access it这个 window 有一个单独的 html 代码,我不明白如何访问它
I think the query is related to switching tabs.我认为查询与切换标签有关。 Try this:
尝试这个:
driver.switch_to.window(driver.window_handles[1])
driver.switch_to.window(driver.window_handles[1])
In driver.window_handles[]
method, you are required to specify the index of the tab in []
[0]
is the first tab, [1]
is the second tab, and so on.在
driver.window_handles[]
方法中,需要在[]
中指定选项卡的索引, [0]
为第一个选项卡, [1]
为第二个选项卡,依此类推。 I think this should clear the doubt.我认为这应该可以消除疑问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.