1

I'm trying to go to a LinkedIn website. I'm using Selenium and for some reason it does not recognize my saved user name and password so every time I open up a LinkedIn session, it is prompting me for those, but first since I already have an account, I have to click the Sign In 'button.' I'm pretty new to Selenium and not sure how to reference the web element.

This is a shortened version of the URL I get tripped up on: https://tinyurl.com/ygyw7eeo

This is a portion of what I think is the relevant HTML: Sign in

What I need is the VBA code to recognize that element and click "Sign Up" to take me to the next page where I input my email and password, then hit the Login button.

I've spent days on this and no idea so any help would be greatly appreciated. Thanks.

Private Sub Command175_Click()


Dim SeleniumEdgeDriver As New EdgeDriver
Dim strEdgeProfile As String
Dim SignInButton As Variant


'strEdgeProfile = "C:\Users\Jerry\AppData\Local\Microsoft\Edge\User Data\Personal"
strEdgeProfile = "C:\Users\Jerry\AppData\Local\Microsoft\Edge\User Data\Profile 1"
'.AddArgument ("profile-directory=foldername") 'foldername is the name of the folder with the profile you want to use


SeleniumEdgeDriver.SetProfile strEdgeProfile, True
SeleniumEdgeDriver.AddArgument ("--user-data-dir=C:\Users\[NAME]\AppData\Local\Microsoft\Edge\User Data\Default")
SeleniumEdgeDriver.AddArgument ("profile-directory=C:\Users\[NAME]\AppData\Local\Microsoft\Edge\User Data\Default")
SeleniumEdgeDriver.Get ("http://www.google.com")
SeleniumEdgeDriver.Get ("https://www.linkedin.com/feed/")

'Wait for the page to load code
While SeleniumEdgeDriver.ExecuteScript("return document.readyState") <> "complete"
    SeleniumEdgeDriver.Wait (5000)
Wend


'Click the Sign in button-All of the commented out things are what I've tried that didn't work!
'I tried to set my user profile where the login name and password were stored and that is not working
"I also tried to code to click the sign in button and that is not working becuase I'm not properly referecing the object

'SignInButton = SeleniumEdgeDriver.FindElementByName("auth_wall_desktop_profile-login-toggle")
'SignInButton.Click

'SeleniumEdgeDriver.FindElement(By.linktext("Sign in")).Click
'SeleniumEdgeDriver.FindElementByLinkText("Sign in").Click

'SeleniumEdgeDriver.FindElementByXPath("//button.form-toggle").Click

'SeleniumEdgeDriver.FindElementsByXPath("/html/body/main/div/div/form[2]/section/p/button").Click
'SignInButton = SeleniumEdgeDriver.FindElementsByXPath("/html/body/main/div/div/form[2]/section/p/button", 100, 100)
'SignInButton.Click

'SeleniumEdgeDriver.FindElementByClass("form-toggle", 2000).Click
'SeleniumEdgeDriver.FindElementById("auth_wall_desktop_profile-login-toggle", timeout:=0).Click  ' no implicit waiting
'SeleniumEdgeDriver.FindElementByXPath("//a[@class='challenge-dialog']").Click

'SeleniumEdgeDriver.FindElementsByClass("p").Attribute("form-toggle").Click
'driver.FindElement (By.cssSelector("#shipping-method-buttons-container button"))
'SeleniumEdgeDriver.FindElementByCss("profile-card hidden").Click

'SeleniumEdgeDriver.FindElementByTag("Button", 2000, False).Click

'SeleniumEdgeDriver.FindElementByXPath("//div[@class ='data-tracking-control-name']/button/span/span[text()='Sign in']").Click


'SeleniumChromeDriver.Manage().DeleteAllCookies
SeleniumEdgeDriver.window.Maximize
SeleniumEdgeDriver.Wait 12000
SeleniumEdgeDriver.Quit

End Sub
2
  • Welcome. Can you add your code to your question? It'll help the community figure out what's going on and give proper advice. Without a code sample, we're just guessing. Two, are you sure you want to use VBA? That's not a very common language to use for Selenium, so help might be hard to find.
    – Lee Jensen
    Apr 27 at 19:33
  • Yes, unfortunately I have to be in VBA. My data is in Microsoft Access and VBA is the code of choice there. Usually I'm able to adapt from other languages as I can usually map the syntax. Thanks so much for your help.
    – JerryW
    Apr 28 at 13:29
1

for some reason it does not recognize my saved user name and password so every time I open up a LinkedIn session

By default, Selenium opens a "guest" window when running.

code to recognize that element and click "Sign Up"

You can use XPath //a[text()='Sign in'] to select the <a href="#">Sign in</a> link and then use XPath //button[text()='Sign in'] to select the <button>Sign in</button> button.

1
  • thanks so much for your reply. Earlier today I was able to use this to get it to work, but will also tried your solution: SeleniumEdgeDriver.FindElementByLinkText("Sign in").Click();
    – user49364
    Apr 29 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.