程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了切换到Selenium Webdriver中的Web对话框:Python大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决切换到SELEnium Webdriver中的Web对话框:Python?

开发过程中遇到切换到SELEnium Webdriver中的Web对话框:Python的问题如何解决?下面主要结合日常开发的经验,给出你关于切换到SELEnium Webdriver中的Web对话框:Python的解决方法建议,希望对你解决切换到SELEnium Webdriver中的Web对话框:Python有所启发或帮助;

试试这个:

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

解决方法

我要处理SELEnium Web驱动程序(Internet Explorer)下的Web对话框。我正在使用Python

在我的应用程序中,单击“图标”时,将打开一个包含一些文本框(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")

这是我得到的错误

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'

供您参,该网络元素的名称和截止日期相同。

有人可以帮我这个忙吗?

大佬总结

以上是大佬教程为你收集整理的切换到Selenium Webdriver中的Web对话框:Python全部内容,希望文章能够帮你解决切换到Selenium Webdriver中的Web对话框:Python所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。