Microsoft Edge WebDriver- Unable to use default ap

2020-05-01 09:42发布

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 Default Profile Path

C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default

(Edge driver) path -

C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default

1条回答
做自己的国王
2楼-- · 2020-05-01 10:33

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/");
    }
}

Please note that this needs to use selenium-server-4.0.0-alpha-4 which you can download form here.

查看更多
登录 后发表回答