问题描述
我必须使用现有的用户登录会话,我们将需要EDGE用户配置文件,因为我们观察到EDGE驱动程序不会使用现有的用户数据配置文件,而是每次都会创建一个新的配置文件
I have to use existing user login session, we will require EDGE user profile, as we observed EDGE driver doesn't use the existing user data profile it is creating a new profile every time
EDGE默认配置文件路径
EDGE Default Profile Path
C:\ Users \ edge2automation \ AppData \ Local \ Microsoft \ Edge \ User Data \ Default
C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default
(边缘驱动程序)路径-
(Edge driver) path -
C:\ Users \ edge2automation \ AppData \ Local \ Temp \ scoped_dir64860_1277252271 \ Default
C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default
推荐答案
由于新的Edge基于Chromium,我们可以参考并将关键字更改为Edge:
As the new Edge is based on Chromium, we can refer to the solution of using Chrome profile and change the key words to Edge:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("user-data-dir=C:\\Users\\edge2automation\\AppData\\Local\\Microsoft\\Edge\\User Data");
edgeOptions.addArguments("--start-maximized");
WebDriver driver = new EdgeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
请注意,这需要使用selenium-server-4.0.0-alpha-4,您可以下载这里.
Please note that this needs to use selenium-server-4.0.0-alpha-4 which you can download form here.
这篇关于Microsoft Edge WebDriver-无法将默认应用程序数据配置文件用于自动化-Edge Ver 80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!