打开URL后试图在Chrome浏览器上填写数据并点击按钮



我是一个使用VBA Excel尝试通过Chrome打开URL填写数据并点击提交按钮。

我能够编写打开URL的命令,但我不确定如何继续键入数据并提交表单

My Code以

开头
Sub OpenHyperlinkInChrome()
Dim chromeFileLocation As String
Dim hyperlink As String
hyperlink = "<URL OVER HERE>"
chromeFileLocation = """C:Program FilesGoogleChromeApplicationchrome.exe"""
Shell (chromeFileLocation & "-url " & hyperlink)

driver.FindElementByName("trackingId").Value = "123"
driver.FindElementByID("epm-submit-button-announce").Click
End Sub

我在"driver.FindElementByName."上得到一个语法错误

我的字段HTML代码读作

<input type="text" placeholder="Example: BLUE_SHOES_08. This information is for your tracking purposes." name="trackingId" class="a-input-text a-span12">

按钮的HTML代码读作

<span id="epm-submit-button-announce" class="a-button-text a-text-center" aria-hidden="true">
Submit
</span>

我该如何填写表格并提交?

问题是您正在调用"驱动程序";对象,而不定义它,甚至不声明它。从代码来看,您似乎正在尝试使用Selenium,您安装了Selenium吗?安装Selenium之后,代码应该如下所示:

Set driver = CreateObject("Selenium.ChromeDriver")
driver.start "chrome"
driver.Get "<URL OVER HERE>"
driver.FindElementByName("trackingId").SendKeys ("123")
driver.FindElementByID("epm-submit-button-announce").Click

最新更新