I have a small Macro taking me a to a website on Chrome using a shell command, but I'm hoping to chain it to another that populates the username and password on the site. Is this possible? My code so far:
Sub Logintest2()
Dim chromePath As String
chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
Shell (chromePath & " -url http://www.google.com")
End Sub
I found a post on Reddit that says this is much easier using Internet Explorer since Excel/VBA has some built in interop. However, if you're anything like me you abhor IE.
The same Reddit post suggested a third party plug-in called Selenium Basic . I used this answer to download and install it.
The following code successfully opened Google in Chrome and set the text of the search box to "This is a test".
Sub Test()
Dim bot As New WebDriver
bot.Start "chrome", "https://www.google.com"
bot.Get "/"
bot.FindElementByName("q").SendKeys "This is a test"
Stop
End Sub
I used DevTools (F12) to explore the web content and find that the search box has name="q"
.
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.