We may come across several situations in which we need to use our SSO access to login to an application.
But while launching a new browser using we will be always getting a fresh profile which does to consider our SSO.
So we need to create a browser profile which uses our existing user data and also the extensions which are needed to login with SSO such as Windows 10 Chrome extension
The following error will be shown on such issues
On Chromium/Edge:
You can't get there from here
This application contains sensitive information and can only be accessed from:
Devices or client applications that meet <Org Name> management compliance policy.
You need to be signed in to Microsoft Edge with the work or school account shown above. To sign in, click on your account image. Learn More
Sign out and sign in with a different account
More details
On Chrome:
You can't get there from here
This application contains sensitive information and can only be accessed from:
Devices or client applications that meet <Org Name> management compliance policy.
Since you're using Chrome, you need to install this extension. You must be on Windows 10 version 1703 and above. Alternatively, you can use Microsoft Edge or Internet Explorer to access this application.
Sign out and sign in with a different account
More details
In the case of chrome, we need to install the windows 10 extension also at first.
For this extension to work we may have to allow extensions also while creating a browser profile.
Now let's see how this works when we are using selenium C# to automate this process:
- At first, we need to get the logged-in User Name, We can get it using the code below in C#
string currentUser = System.Environment.UserName;
- Next, we need to use this in the driver options as an argument
ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions .AddArguments(@"user-data-dir=C:\Users\" + currentUser + @"\AppData\Local\Google\Chrome\User Data");
1 2 3 4 5 6 7 8 | string currentUser = System.Environment.UserName; //read the Logged in user name ChromeOptions chroptions = new ChromeOptions(); chroptions.AddArguments("--noerrdialogs"); chroptions.AddArguments(@"user-data-dir=C:\Users\" + currentUser + @"\AppData\Local\Google\Chrome\User Data"); chroptions.AddAdditionalCapability("useAutomationExtension", false); chroptions.AddArgument("no-sandbox"); driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), chroptions, TimeSpan.FromMinutes(3)); |
No comments:
Post a Comment