Microsoft Edge WebDriver- Unable to use default app data profile for Automation - Edge Ver 80

五迷三道 提交于 2020-04-07 08:27:10

问题


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:


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.



来源:https://stackoverflow.com/questions/60439395/microsoft-edge-webdriver-unable-to-use-default-app-data-profile-for-automation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!