您好老师,我最近在学习您的SeleniumBasic 3.141.0.0-在VBA中操作浏览器的应用,看了好几遍,还是不理解,请问我该怎样在这个网页的用户名输入“333999”,在密码框中输入“123456”,并提交页面?谢谢!
<html>
<head>
</head>
<body>
<form class="el-form el-form--label-left" style="box-sizing: border-box; width: 282.737px; height: 370.938px; margin: 0px auto; background-color: white">
<div class="el-form-item is-required" style="box-sizing: border-box; ">
<label for="name" class="el-form-item__label" style="box-sizing: border-box; ">
用户名</label><div class="el-form-item__content" style="box-sizing: border-box; ">
<div class="login-input el-input" style="box-sizing: border-box; ">
<input type="text" autocomplete="off" maxlength="64" placeholder="请输入用户名" class="el-input__inner" style="box-sizing: border-box; " name="T1" size="20"></div>
</div>
</div>
<div class="el-form-item is-required" style="box-sizing: border-box; ">
<label for="password" class="el-form-item__label" style="box-sizing: border-box; text-align:">
密码</label><div class="el-form-item__content" style="box-sizing: border-box; ">
<div class="login-input el-input" style="">
<input type="password" autocomplete="off" maxlength="64" placeholder="请输入密码" class="el-input__inner" style=""></div>
</div>
</div>
<div type="primary" class="btn-login" style="">
LOGIN</div>
</form>
</div>
</body>
</html>
** 一直弄不对,请指教,谢谢!**
Private WD As SeleniumBasic.IWebDriver
Sub Baidu()
On Error GoTo Err1
Dim Service As SeleniumBasic.ChromeDriverService
Dim Options As SeleniumBasic.ChromeOptions
Set WD = New SeleniumBasic.IWebDriver
Set Service = New SeleniumBasic.ChromeDriverService
With Service
.CreateDefaultService driverPath:=“E:\chrome85“
.HideCommandPromptWindow = True
End With
Set Options = New SeleniumBasic.ChromeOptions
With Options
.BinaryLocation = “C:\Program Files\Google\Chrome\Application\Chrome.exe“
.AddExcludedArgument “enable-automation“
.AddArgument “--start-maximized“
End With
WD.New_ChromeDriver Service:=Service, Options:=Options
WD.URL = “http://214/alms/login“
Dim form As SeleniumBasic.IWebElement
Dim text As SeleniumBasic.IWebElement
Dim password As SeleniumBasic.IWebElement
Dim primary As SeleniumBasic.IWebElement
Set form = WD.FindElementById(“div“)
Set text = WD.FindElementByName(“Text“)
text.SendKeys “333999“
Set password = WD.FindElementByTagName(tagName:=“input“)
password.SendKeys “123456“
Set primary = WD.FindElementByType(Type:=“primary“)
primary.Click
MsgBox “下面退出浏览器。“
WD.Quit
Exit Sub
Err1:
MsgBox Err.Description, vbCritical
End Sub