无法使用Excel VBA Selenium登录

时间:2018-07-01 18:24:27

标签: excel vba excel-vba selenium

因此,我正在尝试创建一个脚本,该脚本将自动在此网站上为我登录:

https://teespring.com/login

到目前为止,这是我的脚本:

Alamofire.request(_evolutionURL).responseJSON { response in

                if let dict = response.result.value as? Dictionary<String, AnyObject> {

                    if let evoLvl = dict["min_level"] as? String {

                        self._nextEvolutionLvl = evoLvl

                    }
                }
            }

因此,我尝试使用以下代码行输入我的用户名:

Sub openBrowser()

'Open new browser
Set driver = New Selenium.ChromeDriver

'Navigate to Website
urlWebsite = "https://teespring.com/login"
driver.Get urlWebsite

但是我收到一个错误消息,说元素不可见

还有什么方法可以使登录过程自动化?

感谢您的帮助,如果您需要更多信息,我将尽我所能,因为我仍在学习如何处理vba硒:-)

1 个答案:

答案 0 :(得分:1)

它不可见,因为它在表单内部。

Login fields in form

您需要通过表单访问:

Option Explicit
Public Sub EnterInfo()
    Dim d As WebDriver
    Set d = New ChromeDriver
    Const URL = "https://teespring.com/login"
    With d
        .Start "Chrome"
        .get URL
        With .FindElementByClass("js-email-login-form")
            .FindElementByCss("input[name=email]").SendKeys "myEmail"
            .FindElementByCss("input[name=password]").SendKeys "myPassWord"
            .FindElementByCss("input[type=submit]").Click
        End With
        Stop '<==  Delete me after inspection
        .Quit
    End With
End Sub