0

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 Answers1

1

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.

Sam
  • 5,424
  • 1
  • 18
  • 33
  • Thanks, Sam. It works. it inputs the credentials and able to click the Sign in button. However, could you pls let me know what do you mean by "you need to init some scripts at the page"? – rahmaddanis Apr 25 '23 at 05:58
  • It is build with the Ember framework, which I know nothing about. It seems as if the page is built in an iframe and later on moved out to the main frame. I don't know if that is an issue or not. – Sam Apr 25 '23 at 07:58
  • Once I logged in, I can't input the form fields. I have problem with getting the element by id. Is that what you mean? – rahmaddanis Apr 25 '23 at 08:23