Selenium VBA chrome cannot open website after setting default profile with . SetProfile - excel

I want to get data from a website where I need to log in. If I open the website manually via Chrome, I can log in with my user name and password. If I do the same with chrome via selenium vba, the website requires an extra authentication step that I cannot automate. So I have tried to add profile information to the driver with ".SetProfile". There is a default profile and 5 other profiles in ".../UserData", but none of the latter is my standard profile. So I opted for the default profile. Doing this, Chrome asks me to choose one of the available profiles. After choosing the desired profile (my standard profile, which has already a window open), the script should open the log-in page, but nothing happens. No error message, no new tab or window opening, nothing. I can get to this point by debugging step by step, but after this step, I lose control, cannot do any further steps.
As long as I do not include the ".SetProfile" step, the script works fine, with the mentioned limitation that the website then requires a 2-step authentication.
Sub CheckThis(Target, Cancel)
......
With chrome
.SetProfile "C:\Users\username\AppData\Local\Google\Chrome\User Data", True
.Start 'here, Chrome asks me to choose a profile and then nothing else happens anymore
.Get "website.com"
Set user_email = .FindElementById("login-email")
user_email.SendKeys ("userName")
Set siguiente = .FindElementById("login-submit")
siguiente.Click
Set Password = .FindElementById("login-password")
Password.SendKeys ("Password")
Set iniciar = .FindElementById("login-submit")
iniciar.Click
(the rest is irrelevant for the issue)

I think I understand now why it does not work and why it probably cannot work.
This is what I tried:
I closed the existing open Chrome window with all its tabs before running the script. After the ".SetProfile" line, Chrome asked me again, which profile I want to use. When I chose my standard profile, the Chrome Window that I had just closed, opened again, but the desired webpage did not open.
Then I tried again, this time running the script until ".Start" without the ".SetProfile". This opened an empty Chrome window without any profile, as expected. Then I tried to log in to this instance of Chrome manually with my usual profile. The log-in was rejected after entering my username. Checking the error info, I found that, among others, Google does not allow logging in if the browser is not controlled by a person but by an automatization software which, of course, is the case when I open Chrome from Selenium.
This means, there seems to be no solution for my problem. Without logging in to my Chrome profile, the web page will always require 2-step authentication, and logging in to a Chrome profile is not possible if Chrome is controlled by VBA.

Related

SeleniumBasic and Controlling Existing Edge Browser

For the past few months, I have been using SeleniumBasic with Excel and Microsoft Edge and have created some pretty useful macros for our company.
The problem I can’t seem to solve is being able to control an existing Edge/Chrome browser window that’s already open thru Excel/VisualBasic.
I have done quite a bit of searching and have found a few existing discussions regarding this subject. From what I have read and gathered, what I am trying to do is impossible with SeleniumBasic. However, there is no explanation as to why this is.
Is this just a limitation of SeleniumBasic? I understand it is fairly outdated and hasn’t been updated in a while. I know there’s code in python and java that allows you to extract existing session id through Selenium, and controlling an already open browser instance can be achieved.
I guess ultimately what I’m trying to figure out is if there is any way at all to incorporate into an excel macro coding that would allow control of an existing browser session (Chrome/Edge). Are there alternatives to SeleniumBasic that would allow me to achieve this?
Presently, my macro opens a new instance of Edge, goes to a specific website for our company (which requires login and 2FA), then once logged in, takes the data in the excel sheet and inputs the data into the site. The big annoyance here is the logging in/2FA part. Every time the macro is run, have to redo 2FA and takes up a bunch of time. Ideally would love to login just once, do the 2FA and proceed with the macro.
Anyone have any ideas/suggestions? Am I just SOL? 😅
You can't control an existing browser through SeleniumBasic.
From your description, I think you can open the browser with a specific profile as a workaround. For example, you can remember the login information in a profile, every time you open the website using that profile, it will login automatically.
To open browser with specific profile, you can refer to the following code (I test it only works with Chrome):
Public Sub Test()
Dim driver As New Selenium.ChromeDriver
'If you use the Default profile, you only need to set user-data-dir. Change the UserName to your owns
driver.AddArgument ("--user-data-dir=C:\Users\UserName\AppData\Local\Google\Chrome\User Data")
'If you use other profile, you need to set profile-directory with profile folder name
'driver.AddArgument ("profile-directory=Profile 1")
driver.Get "https://www.google.com"
driver.Wait 3000
driver.Quit
End Sub

Can't signin into microsoft account

I didn't have any problems before with signin into ms account, but now I can't get access to any account (to my account and even to new accounts) from any browser on my pc (but can signin from other pc, so, I know for sure - my account is active and havn't been blocked).
How it works (or, actually, doesn't):
1. Open https://azure.microsoft.com/en-us/services/devops/
2. click on "Sign in to Azure DevOps"
3. enter email and press enter
4. after few seconds and few requests (and few redirects), browser shows signin page again
OR:
1. Open https://portal.azure.com
2. enter email and press enter
3. after few seconds and few requests (and few redirects), I retrieve page "Sign-in failed. Sorry, we had some trouble signing you in, Click 'Try again' to try again."
Other details:
OS: Windows (maybe it happend after latest windows update, I'm not sure)
No installed antivirus or security software (just windows defender)
Browsers: Chrome, Edge on chromium, Firefox, Opera
It happened one week ago, and I still can't signin
There is no failed responses (4xx or 5xx), and no errors in console, so I really dont know how to fix it, maybe someone can help me with this problem
Importang thing: If I change network from my home wifi to another, I can signin there, so problem somewhere in wifi/router
Check to see what's under Credential Manager and, if the account is there, clear it out.
To go there, simply open Start and type credential manager.
You should be good to go.

How to handle browser popup in Robot framework when monitor screen is close

My script in Robot framework use White library to find a popup window and authenticates a user by entrering his username and password, then clicking on button to connect.
The script works well when monitor screen is open but fails when monitor screen is closed (i.e. windows session locked (ctrl+alt+del)). Script must be launched automatically any time by Jenkins. For this reason no screen is needed during test execution.
I have tried with Autoit library too without success, and I also tried to send credentials in URL like this "http://user:password#myserverurl.com". Which did not work because this popup appears in middle of the scenario of another application which authentication has already been made through another login page in the beginning of scenario.
Please send me your suggestions if there is a way to simulate an opened monitor screen or another library that I can use to handle browser popup when monitor screen is close.
Thank you in advance. My code :
WhiteLib.Attach Window ${windowTitle}
WhiteLib.Press Keys ${user}
WhiteLib.Press Special Key TAB
WhiteLib.Press Keys ${password}
WhiteLib.Press Special Key TAB
WhiteLib.Press Special Key RETURN

Google OAuth not working when a user clicks from a LinkedIn link

When a user clicks a link to my site inside their LinkedIn app it doesn't take them to Safari or Chrome, it keeps them in an internal LinkedIn browser.
If the user then tries to create an account via Google OAuth they get the following error (see image).
Is there a way to prevent LinkedIn from opening a link in their proprietary browser, and take them to Safari or Chrome automatically? Or another workaround for this issue?
Neither you can restrict LinkedIn to open your site in other browser nor to stop google to throw the error. To solve this problem, You have to write a script which will open your website in the default browser of the user's device. Whenever user hit your website then check the web browser if it's chrome, safari or any other web browser then continue the request else force the user to open website in user's default browser using the script. That's it.
Hope this suggestion will help you.

Creating a Firefox extension to edit "network.automatic-ntlm-auth.trusted-uris"

On the sharepoint site we're developing at work, people are able to log into the site using IE 7, but when prompted for the username and password on firefox 3, it doesn't matter how many times you try to log on, the username/pass window keeps popping up. If you click cancel it denies you access into the site.
We've tried to fix the issue for our individual machines by:
1) logging into IE 7, clicking "save password" when logging in.
2) Then going into firefox, typing about:config,
3) Search for URIs
4) Adding ".csom.umn.edu" to the value column for the three results that popup.
This is a long and complicated procedure for our clients, would it be possible to create an extension or add-on that would automate this procedure just by downloading it after the first failure of logging on with firefox?
Thank you!
Try this
http://markmonica.com/2007/11/20/firefox-and-integrated-windows-authentication/

Resources