vkr*_*ams 3 python selenium internet-explorer webdriver
我想在selenium web驱动程序(Internet Explorer)下处理一个Web对话框.我正在使用Python
在我的应用程序中,当我单击Icon时,会打开一个包含一些文本框(Webelements)的Web对话框,我需要在输入一些文本后单击"保存"按钮.问题是我不知道焦点是否已切换到Web对话框.这是我的代码
driver.find_element_by_xpath("//img[contains(@src,'/images/btn_add.gif')]").click()
driver.switch_to_alert()
driver.find_element_by_name("report_cutoff_date").sendkeys("10/31/2010")
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误
Traceback (most recent call last):
File "C:\Users\vthaduri\workspace\LDC\test.py", line 14, in <module>
driver.find_element_by_name("report_cutoff_date").sendkeys("10/31/2010")
File "C:\Python27\lib\site-packages\selenium-2.21.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 282, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "C:\Python27\lib\site-packages\selenium-2.21.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 651, in find_element
{'using': by, 'value': value})['value']
File "C:\Python27\lib\site-packages\selenium-2.21.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 153, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-2.21.2-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 147, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to find element with name == report_cutoff_date'
Run Code Online (Sandbox Code Playgroud)
为了您的信息,webelement具有相同的名称和截止日期.
有人可以帮我这个.
试试这个:
parent_h = browser.current_window_handle
# click on the link that opens a new window
handles = browser.window_handles # before the pop-up window closes
handles.remove(parent_h)
browser.switch_to_window(handles.pop())
# do stuff in the popup
# popup window closes
browser.switch_to_window(parent_h)
# and you're back
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16854 次 |
最近记录: |