Automating Edge with CDP using VBA fails on Linkedin developer site

191 Views Asked by At

I'm trying to automate Edge browser with CDP using VBA written by ChrisK23

I prefer this method because I don't want to install Selenium drivers.

It works well with Google using the sample code but somehow it fails when working with the Linkedin developer site: https://www.linkedin.com/developers/apps/new

It fails to input my credentials using the following:

Call objBrowser.jsEval("document.getElementById(""username"").value='" & myEmail & "';")
Call objBrowser.jsEval("document.getElementById(""password"").value='" & myPwd & "';")

I found the page was loaded completely but can't get the credential elements which are username input field, password input field, and sign in button.

Have tried several methods to get the element(s) (by name or looping through) but not success.

Any ideas?

1

There are 1 best solutions below

3
Sam On BEST ANSWER

The page loads into an iframe at first. The embedded code in your snippet looks something like this

document.getElementById("username").value='something';

Changing it to access it via the iframe like this

document.getElementsByTagName("iframe")[0].contentDocument.getElementById("username").value="something"

will give you access to the expected element. Putting it back into your call

Call objBrowser.jsEval("document.getElementsByTagName(""iframe"")[0].contentDocument.getElementById(""username"").value='" & myEmail & "';")

It might be that this isn't the full solution and you need to init some scripts at the page. It is a start though.