Selenium在没有html的弹出式页面上登录

问题描述 投票:0回答:1

在我的Selenium程序中,我使用google-chrome驱动程序访问并登录到此webpage上的帐户。问题是登录网页是一个带有弹出窗口的程序,没有任何我可以抓取的HMTL代码。因此,我不知道如何键入我的凭据。我环顾四周,看到了一些带有“动作”的建议,例如

actions = ActionChains(driver)
actions.send_keys('skdkds')
actions.perform()

但是问题是,它没有输入任何内容,仅将光标放在第一个字段中。我想这是程序安全性的一部分,但是通过将光标放置在正确的位置,我应该能够将键发送给驱动程序,然后与tab命令一起移动。但是我不知道如何。

任何帮助将不胜感激。非常感谢]]

对于可重现的示例:

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
import pandas as pd
import datetime
import time
import glob
import os

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get(link_mentionned_above) //then I am blocked 

更新

如Azy_Crw4282所述,问题在于处理警报,但是驱动程序无法识别任何警报,因为对于driver.switch_to_alert(),我收到错误消息:

  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/alert.py", line 67, in text
    return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"]
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoAlertPresentException: Message: no such alert

在我的Selenium程序中,我使用google-chrome驱动程序访问并登录此网页上的帐户。问题在于,登录网页是一个带有弹出窗口且没有任何HMTL的程序...

python selenium popup
1个回答
0
投票

您下面的代码不正确,因为它没有明确处理提示警报。

© www.soinside.com 2019 - 2024. All rights reserved.