如何用python selenium关闭弹出窗口?
毕业设计
1
输入身份证号后,点击校验,出现弹出窗(无法移动弹出窗,也无法查看源代码),使用了alert、confirm方法也无法关闭窗口,求关闭弹出窗口代码。
-
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select from pymouse import PyMouse mouse = PyMouse() import time chromedriver = r"C:\Program Files (x86)\chrome32_50.0.2661.75\chromedriver.exe" driver= webdriver.Chrome(chromedriver) driver.get("http://58.51.146.211:808/**") driver.find_element_by_xpath("//a[@onclick='openwin(8);']").click() driver.find_element_by_name("loginname").send_keys(u"****") driver.find_element_by_name("pwd").send_keys(u"123456") driver.find_element_by_link_text("确定").click() time.sleep(5) driver.find_element_by_xpath("//a[contains(@href, 'difficultydisability.do?method=dataMainte&forward=dataMainte_enter')]").click() time.sleep(5) driver.switch_to.frame(0) driver.find_element_by_name("difficultydisabilityForm.card_id").send_keys(u"123456197209**0056") driver.find_element_by_name("Submit823").click() time.sleep(5)#以前用driver.implicitly_wait(5) 没有成功 mouse .click(700,180,1)
试一哈
发表回复