VBA to navigate website with dropdown menu

pingme89

Board Regular
Joined
Jan 23, 2014
Messages
176
Office Version
  1. 365
Platform
  1. Windows
I am trying to get to the login screen and automatically enter the username and password and clicking on Enter.

I have been successful on other sites but the following site has a "Login" button that functions as a dropdown menu.
I can't figure out how to navigate past the dropdown menu to get to the login screen.

The website is: https://dealersocket.com/

On the upper right side of the webpage, there is a button called "Login". If I manually click it, a dropdown menu of various logins appear. I want to be able to log into the Dealersocket choice.

How can I automate that with VBA? Any help would be greatly appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
The dropdown is a list of buttons that navigate to different Urls... why not just copy down those Urls directly into the code and you can make a userform or inputbox to choose which one you want to navigate to??
 
Upvote 0
I tried that too.

Every time I copy the URL to the login page of Dealersocket, I get a different URL every time.

Example: https://sso.dealersocket.com/login?signin=2f117695287c15bf501d63936230f434

If I try it again, I get a different URL: https://sso.dealersocket.com/login?signin=c00cd16b9b33bbe39786876b6b7f5445

If I use any of those URLs in my code, the site gives me an error message saying: "There is an error determining which application you are signing into. Return to the application and try again.
 
Upvote 0
How are you interacting with this website? IE automation?

You should probably be handling the communication with the website yourself. You can create GET or POST httprequests and parse the html responses... those values should be given to you by the website when you navigate to those login pages. I actually helped someone parse yahoo finance a while back... there is code for sending requests to websites on it. You should be reading the html yourself. That special login key should be sent to you by the webpage in the response headers or response html... you most likely have to do a couple requests to get to the login.

Here is that old thread... the post I linked has code for a function to pull html from the website but you can use the objects to also read response headers... you just need to debug how the website interacts and then mimic it with your requests.


https://www.mrexcel.com/forum/excel-questions/1005735-pull-data-website-4.html#post4828663
 
Upvote 0
For example to get to the login for...

https://my.dealersocket.com/

You will need to send a request to that Url, then somewhere in the response will be the url with all the numbers and then you make a second request to go there
 
Upvote 0
If you check the network traffic in the developer tools of your browser, you will see to get to the login page you need to send a POST request to... https://dealersocket.com/php/headernav-login.php and the post data you send is... {"button":"login-dealersocket"}

Aq1vypb.png
 
Upvote 0
I tried using your function, but I get no results. I am not that familiar with HTML and especially difficult with this set up with responses. Can you give me a bit more guidance?
 
Upvote 0
This is the code I have so far, but as you know, as it is, it doesn't work. What would I need to change to make it work?

Dim wbname As String
Dim wsname As String
Dim objIE As SHDocVw.InternetExplorer 'microsoft internet controls (shdocvw.dll)
Dim HTMLDoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Dim HTML_Element As IHTMLElement
Dim objCollection As Object
Dim objElement As Object

wbname = ActiveWorkbook.Name
wsname = ActiveSheet.Name

Set objIE = New SHDocVw.InternetExplorer




Call ParseYahooFinanceTable(MakeGetRequest("https://my.dealersocket.com/"))





With objIE
.Navigate "https://sso.dealersocket.com/login?signin=2f117695287c15bf501d63936230f434"
.Visible = 1
Do While .ReadyState <> 4: DoEvents: Loop
Application.Wait (Now + TimeValue("0:00:02"))

'set user name and password
Set HTMLDoc = .Document
Set htmlColl = HTMLDoc.getElementsByTagName("username")
Do While HTMLDoc.ReadyState <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If htmlInput.Name = "username" Then
htmlInput.Value = Workbooks(wbname).Worksheets("Settings").Range("D30").Value
Else
If htmlInput.Name = "password" Then
htmlInput.Value = Workbooks(wbname).Worksheets("Settings").Range("D31").Value
End If


End If
Next htmlInput
End With


SendKeys "{Enter}", True


Set ie = Nothing
Set objElement = Nothing
Set objCollection = Nothing
 
Upvote 0
I tried using your function, but I get no results. I am not that familiar with HTML and especially difficult with this set up with responses. Can you give me a bit more guidance?
 
Upvote 0
Try:
Code:
objIE.Navigate "https://my.dealersocket.com"
Please use CODE tags with VBA code.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top