1

I have an automation test suite that runs perfectly on Chrome. Now I want to extend my test runs on other browsers EDGE, FF.

Problem: When I try to launch EDGE browser I'm getting dialogue 'Sync Your Profile'. I tried with different edge options but couldn't handle/close this.

Image: enter image description here

Dialogue displayed with text:

*Sync your profile XXXXXXX@ABC-software.com has signed in on this device, so we've also signed you in to Microsoft Edge.

Sync isn't available for this account.

To sign out, go to Settings > Profiles.

Microsoft Privacy Statement*

Edge version:

Edge Browser Version: 103.0.1264.62 MS Edge driver: 103.0.1264.49

I have tried below option during browser launch.

        EdgeOptions edgeOptions = new EdgeOptions();
        Map<String, Object> edgePrefs = new HashMap<String, Object>();
        edgePrefs.put("credentials_enable_service", false);
        edgePrefs.put("profile.password_manager_enabled", false);
        edgeOptions.setExperimentalOption("prefs", edgePrefs);
        edgeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
        edgeOptions.setExperimentalOption("useAutomationExtension", false);
        edgeOptions.addArguments("disable-gpu");
        edgeOptions.addArguments("start-maximized");
        
        edgePrefs.put("profile.default_content_settings.popups", 0);
        edgePrefs.put("profile.default_content_setting_values.notifications", 2);       
        edgePrefs.put("profile.default_content_setting_values.automatic_downloads" , 1);        
        edgePrefs.put("profile.content_settings.pattern_pairs.*,*.multiple-automatic-downloads",1);
        edgeOptions.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
        // Here you set the path of the profile ending with User Data not the profile folder
        edgeOptions.addArguments("user-data-dir="+System.getProperty("user.home")+"\\AppData\\Local\\Microsoft\\Edge\\User Data");
        // Here you specify the actual profile folder
        edgeOptions.addArguments("profile-directory=Profile 1");
    
        driver = new EdgeDriver(edgeOptions);
        driver.get("edge://settings/clearBrowserData");
        driver.findElement(By.id("clear-now")).sendKeys(Keys.ENTER);            

3 Answers3

1

The proper way to resolve this is to disable the Microsoft Edge first-run experience ether by GPO (see this link) or via the registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge] "HideFirstRunExperience"=dword:00000001

This will allow Edge's profile sync to still be enabled on the machine, but you will no longer be presented the dialog popup when running Selenium scripts.

0

To handle Sync your profile alert... Just forget about capabilities and other properties, we can just use ESCAPE KEY to remove the alert using Robot class.

Robot robot = new Robot() ; robot.keyPress(KeyEvent.VK_ESCAPE) ;

IEdriver version : 4.3.0.0 selenium-server : 4.0.0-alpha-2 seleniun-java : 4.4.0 Edge browser version : 104.0.1293.47

0

Starting the Edge driver as private does not open the profile sync screen. However, remember that every time you close the driver, the data stored in the browser, such as cookies, will be lost.

edgeOptions.AddArguments("--inprivate");
TioRAC
  • 111
  • 3