简体   繁体   English

Selenium Python 按下按钮后,一个新的 window 打开,我无法按下那里的键

[英]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.

相关问题 我无法按下 Selenium 和 Python 中的按钮 - I can´t press the button in Selenium with Python 在 Python Tkinter 中按下按钮后如何清除窗口? - How do i clear a window after pressing a button in Python Tkinter? 按下按钮后如何更改 window 内部的内容? - How can i change content inside of a window after pressing a button? 按下 OK 按钮后如何关闭此 tkinter 窗口? - How can I close this tkinter window after pressing the OK button? 无法按下带有 selenium python 的现象级简单按钮 - Can't press a phenomenical easy button with selenium python 如何在 selenium python 中按下打开应用程序按钮 - How can I press the open application button in selenium python python selenium。 下载后如何切换回上一个窗口/标签打开一个新标签 - python selenium . how to switch back to previous window/tab after a download opens up a new tab 使用 selenium + python 按下按钮后 StaleElementReferenceException 错误 - StaleElementReferenceException error after button press with selenium + python 如何在python 2.7中按下按钮“输入”,而无需用户按下它,从代码 - How can I press the button "enter" in python 2.7, without having the user pressing it, from code 在Selenium中打开新窗口后如何自动保存文件 - How to save file automatically after a new window opens in Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM