在将此标记为重复之前,请阅读以下几点,因为我已尝试了所有可能的解决方案:
以下代码:
browser.get("https://www.cnm.att.com/emfe/QNCreateTicket?reportTbl=0&tblValue=DHEC297003811&stateCodeValue=&serviceidtypeValue=&trunkgrpandmessageValue=&testFocusControlID1=idfield1&tblCktValue=DHEC297003811&searchStringForASE=%25DHEC297003811%25&oorInd=null&ASEState=null&isASE_ADEinEMDB=&isASE_ADEinEMDBNotProvisioned=&aseflow=&adeflow=&isASEinEBTA=&searchStringForEditForASE=S%3A2%3ADHEC297003811&button=&clci=&qnfromscreen=quick+navigate&phone=&isProvForTesting=1&isProvForCCA=1&isProvForIP=0&isProvForPhone=1&fromtransporttfn=yes&transporttfn=&circuit_format=&state=&ccid=&cac=&isValidPhoneForUser=&isPOTSDataFound=&localPhoneInd=&circuitId=")
Submit_Ticket = browser.find_element_by_xpath('//*[@id="bottomsec"]/center/table/tbody/tr[2]/td[2]/a/img')
Submit_Ticket.click()
time.sleep(3)
try:
print browser.title
except UnexpectedAlertPresentException as e:
print "exception "+repr(e)
print "msg"+e.msg
print browser.current_window_handle
b = browser.switch_to.window(browser.current_window_handle)
print b
b.send_keys(Keys.RETURN,Keys.ENTER)
输出:
exception UnexpectedAlertPresentException()
msgunexpected alert open: {Alert text : Before submitting this ticket, you must select the following fields:
Trouble Type
Outage Condition
Do you have Power to your Equipment
Authorize Testing
Service Impact}
(Session info: chrome=52.0.2743.116)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86)
CDwindow-be1b9858-ddb0-4470-9c11-5f1420a94c82
None
Traceback (most recent call last):
File "C:\Python27\alert checking.py", line 72, in <module>
b.send_keys(Keys.RETURN,Keys.ENTER)
AttributeError: 'NoneType' object has no attribute 'send_keys'
当我点击弹出窗口时,代码会进一步执行。
答案 0 :(得分:0)
通过将Chrome驱动程序升级到版本2.22来解决此问题,之前它是2.21,这在处理javascript弹出窗口方面存在问题。