Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Selenium的边缘自动化-不断需要凭证_Python_Windows_Selenium_Microsoft Edge_Credentials - Fatal编程技术网

Python 使用Selenium的边缘自动化-不断需要凭证

Python 使用Selenium的边缘自动化-不断需要凭证,python,windows,selenium,microsoft-edge,credentials,Python,Windows,Selenium,Microsoft Edge,Credentials,我想在公司网络内使用Selenium和Python打开例如带有Edge的Google页面 from selenium import webdriver browser = webdriver.Edge(r"C:/_path_to_driver_/msedgedriver.exe") browser.get("https://www.google.com") Edge打开此站点并要求我插入邮件。 输入邮件后,它会将我重定向到此页面: 我必须手动单击“确

我想在公司网络内使用Selenium和Python打开例如带有Edge的Google页面

from selenium import webdriver
browser = webdriver.Edge(r"C:/_path_to_driver_/msedgedriver.exe")
browser.get("https://www.google.com")
Edge打开此站点并要求我插入邮件。

输入邮件后,它会将我重定向到此页面:

我必须手动单击“确定”。Selenium无法单击“确定”。
你知道怎么点击吗?或者有没有办法存储我的邮件地址或证书,而不是总是要求它?此问题仅在边缘由selenium控制时发生。默认边缘会记住所有设置。

如果我们使用selenium webdriver在没有任何参数的情况下自动执行边缘,它每次都会创建一个新的配置文件,而不是使用现有的用户数据配置文件。这就是为什么它每次都要求提供凭证

作为一种解决方法,您可以使用
用户数据目录
配置文件目录
使用特定的配置文件来使用Selenium WebDriver启动Edge。您可以使用存储凭据的配置文件,以便在自动化边缘时它不会请求凭据。我认为在你的情况下,这是默认的边缘轮廓

您需要使用命令
pip install msedge Selenium tools Selenium==3.141安装MS Edge Selenium tools,然后参考下面的示例代码:

from msedge.selenium_tools import Edge, EdgeOptions

edge_options = EdgeOptions()
edge_options.use_chromium = True

#Here you set the path of the profile ending with User Data not the profile folder
edge_options.add_argument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Microsoft\\Edge\\User Data"); 
#Here you specify the actual profile folder
edge_options.add_argument("profile-directory=Profile 2");

driver = Edge(options = edge_options, executable_path = r"C:\_path_to_driver_\msedgedriver.exe")
driver.get('https://www.google.com')
注意:将代码中的路径更改为您自己的路径

如果您不知道特定配置文件的路径,可以检查
edge://version/
如下所示:


如果我们使用selenium webdriver在没有任何参数的情况下自动执行Edge,它每次都会创建一个新的配置文件,而不是使用现有的用户数据配置文件。这就是为什么它每次都要求提供凭证

作为一种解决方法,您可以使用
用户数据目录
配置文件目录
使用特定的配置文件来使用Selenium WebDriver启动Edge。您可以使用存储凭据的配置文件,以便在自动化边缘时它不会请求凭据。我认为在你的情况下,这是默认的边缘轮廓

您需要使用命令
pip install msedge Selenium tools Selenium==3.141安装MS Edge Selenium tools,然后参考下面的示例代码:

from msedge.selenium_tools import Edge, EdgeOptions

edge_options = EdgeOptions()
edge_options.use_chromium = True

#Here you set the path of the profile ending with User Data not the profile folder
edge_options.add_argument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Microsoft\\Edge\\User Data"); 
#Here you specify the actual profile folder
edge_options.add_argument("profile-directory=Profile 2");

driver = Edge(options = edge_options, executable_path = r"C:\_path_to_driver_\msedgedriver.exe")
driver.get('https://www.google.com')
注意:将代码中的路径更改为您自己的路径

如果您不知道特定配置文件的路径,可以检查
edge://version/
如下所示:


您是否在系统上正确安装了edge?它没有安装。。。是正确。您是否在系统上正确安装了edge?它没有安装。。。是的,没错。