Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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 如何使用SeleniumWebDriver查找模式弹出窗口的元素_Python_Selenium_Firefox_Modal Dialog_Webdriver - Fatal编程技术网

Python 如何使用SeleniumWebDriver查找模式弹出窗口的元素

Python 如何使用SeleniumWebDriver查找模式弹出窗口的元素,python,selenium,firefox,modal-dialog,webdriver,Python,Selenium,Firefox,Modal Dialog,Webdriver,我正在使用SeleniumWebDriver和firefox从网站下载真实状态数据。输入输入后,弹出窗口将要求选择'Cancel'或'Save File' 问题是我找不到如何单击这些按钮。我知道它已经是我的驱动程序中的当前窗口,因为我可以更改位置 如果我使用驱动程序。通过xpath('//*')查找\u元素,我会得到以下错误: Traceback (most recent call last): File "<ipython-input-131-e87e382e3fb9>", li

我正在使用SeleniumWebDriver和firefox从网站下载真实状态数据。输入输入后,弹出窗口将要求选择
'Cancel'
'Save File'

问题是我找不到如何单击这些按钮。我知道它已经是我的驱动程序中的当前窗口,因为我可以更改位置

如果我使用
驱动程序。通过xpath('//*')查找\u元素
,我会得到以下错误:

Traceback (most recent call last):

File "<ipython-input-131-e87e382e3fb9>", line 1, in <module>
    driver.find_element_by_xpath('//*')

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 295, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 756, in find_element
    'value': value})['value']

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 238, in execute
    self.error_handler.check_response(response)

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py",
line 193, in check_response
    raise exception_class(message, screen, stacktrace)

NoSuchWindowException: No such content frame; perhaps the listener was not registered
这个问题非常类似于,但我不明白被接受的答案是如何找到选择器的


如果您有任何关于如何解决这个问题的想法,我们将不胜感激

你能提供更多的信息如下:1。提供相关的HTMLDOM。2.如果该URL是公共URL,您可以共享该URL吗?一旦使用您的输入数据(地址、名称)更新网站,该URL可能会重复。如果您向下滚动,最近的销售按钮将允许您下载文件。
Traceback (most recent call last):

File "<ipython-input-142-bd939a2be33d>", line 1, in <module>
    driver.switch_to_alert().accept()

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/common/alert.py",
line 81, in accept
    self.driver.execute(Command.ACCEPT_ALERT)

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 238, in execute
    self.error_handler.check_response(response)

File
"/home/rcortez/anaconda2/envs/webscraper/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py",
line 193, in check_response
    raise exception_class(message, screen, stacktrace)

NoAlertPresentException: No tab modal was open when attempting to get the dialog text