Does exist a way to display a list of profiles (or MS accounts) in MS Edge during Selenium test executions in C#?

67 Views Asked by At

I have several test Microsoft accounts at my work. During Selenium tests execution, I want to display list of all my MS accounts. Is it possible?

enter image description here

1

There are 1 best solutions below

0
Raina Zhao-MSFT On

If you have logged in all your MS accounts in Edge, these accounts would be stored. As long as you specify that Edge profile you have used with Selenium WebDriver like below, these accounts will be listed. If not specify, it will create a new Edge profile to access and there are no accounts stored.

using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System.Threading;

namespace EdgeDriverSample
{
    class Program
    {
        static void Main(string[] args)
        {
            var driver = new EdgeDriver();
            EdgeOptions options = new EdgeOptions();
            // Here set the path of the profile ending with User Data not the profile folder
            options.AddArguments("user-data-dir=C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\Edge\\User Data");
            // Here specify the actual profile folder you have used in Edge
            options.AddArguments("profile-directory=Profile 1");

            driver.Navigate().GoToUrl("https://example.com");
        }
    }
}