Microsoft Edge WebDriver - 无法为自动化使用默认应用数据配置文件 - Edge Ver 80
Microsoft Edge WebDriver- Unable to use default app data profile for Automation - Edge Ver 80
我必须使用现有的用户登录会话,我们需要 EDGE 用户配置文件,因为我们观察到 EDGE 驱动程序不使用现有的用户数据配置文件,它每次都创建一个新的配置文件
EDGE 默认配置文件路径
C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default
(边缘驱动程序)路径 -
C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default
由于新的Edge是基于Chromium的,我们可以参考the solution of using Chrome profile,将关键词改为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,您可以从 here 下载。
我必须使用现有的用户登录会话,我们需要 EDGE 用户配置文件,因为我们观察到 EDGE 驱动程序不使用现有的用户数据配置文件,它每次都创建一个新的配置文件
EDGE 默认配置文件路径
C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default
(边缘驱动程序)路径 -
C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default
由于新的Edge是基于Chromium的,我们可以参考the solution of using Chrome profile,将关键词改为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,您可以从 here 下载。