Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x selenium弹出框交互_Python 3.x_Selenium Chromedriver - Fatal编程技术网

Python 3.x selenium弹出框交互

Python 3.x selenium弹出框交互,python-3.x,selenium-chromedriver,Python 3.x,Selenium Chromedriver,我在与弹出的可拖动窗口交互时遇到一些困难。 运行以下代码后,会出现一个窗口,我可以进行一些自定义。我正试图点击出现的取消全部选择按钮 from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.

我在与弹出的可拖动窗口交互时遇到一些困难。 运行以下代码后,会出现一个窗口,我可以进行一些自定义。我正试图点击出现的取消全部选择按钮

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait

driver.get("https://stats.oecd.org/Index.aspx?DataSetCode=HOUSE_PRICES#")
try:
    customize = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, "customize-icon")))
    print("Customizing")
except TimeoutException:
    print("Loading took too much time!")
selection = driver.find_element_by_id("customize-menu-0")
menu = driver.find_element_by_id("customize-menu-3")
Hover = ActionChains(driver).move_to_element(customize).move_to_element(selection).move_to_element(menu)
driver.execute_script("arguments[0].click()", menu)
我尝试过切换到警报和切换到弹出功能,但我觉得这个网站上显示的东西不是弹出或警报

如果您能帮助访问“弹出式”定制菜单并与之交互,我们将不胜感激。 谢谢

编辑: 似乎在HTML中,弹出表/窗口被称为iframe,它有另一个包含所有内容的HTML标记。iframe包含在ui小部件中,因此我无法直接切换到iframe。

是的,它可以工作:)

添加到上面的代码并直接引用iframe id:

driver.switch_to.frame("DialogFrame")
driver.find_element_by_id("lbtnClear_all").click()
我可以访问“全部取消选择”项目并单击它