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
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.