2016-03-03 81 views
1

我想追查Python Selenium中的错误。该错误消息是..Python硒解密错误消息

Traceback (most recent call last): 
    File "C:\myscipt\main.py", line 110, in <module> 
    source_mysource(func1, func2, func3, func4, func5, func6, func7, func8, func9) 
    File "C:\myscipt\sources\functions.py", line 132, in source_mysource 
    current_url = driver.current_url 
    File "C:\Users\tom\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 454, in current_url 
    return self.execute(Command.GET_CURRENT_URL)['value'] 
    File "C:\Users\tom\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute 
    self.error_handler.check_response(response) 
    File "C:\Users\tom\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response 
    raise exception_class(message, screen, stacktrace, value['alert'].get('text')) 
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. 
<super: <class 'WebDriverException'>, <UnexpectedAlertPresentException object>> 

是误差说行current_url = driver.current_url是触发错误的一个或者是它的下一行?

回答

2

当您使用WebDriver实例的.current_url属性时,会发送GET_CURRENT_URL webdriver命令,这会在您的情况下触发错误。会发生什么情况是,当前打开的网页由于存在警报而不是当前的顶级浏览上下文,并且根据specification,它应该并且因错误而失败。

换句话说,当打开主动警报时,无法检索当前URL。

+0

我想我遵循,所以它不是错误的get_current_url,它只是它突出显示错误。所以我想我需要看看导致警报存在 – fightstarr20

+1

@ fightstarr20是的,错误发生在'current_url = driver.current_url'行。您应该查看为什么此时显示警报。 – alecxe

+0

它是一个奇怪的,我实际上没有看到浏览器中的错误。我可以看到任务栏中的浏览器标签呈蓝色闪烁,通常会显示错误或警报,但没有任何内容 – fightstarr20