简体   繁体   English

使用 selenium v​​ba 在 chrome 中自动登录

[英]auto-login in chrome using selenium vba

i would like to use vba to access a web site and perform other operation once logged in, but i have problem with log in, using this code我想使用 vba 访问网站并在登录后执行其他操作,但我在使用此代码登录时遇到问题

Dim obj As New WebDriver
Dim Keys As New Keys


obj.Start "chrome", ""
obj.Get "https://a14onlinetrackers.azurewebsites.net/trackers/trackerView/1?i=1"


 obj.FindElementByName("loginfmt").SendKeys Keys.Control & "t"

obj.FindElementByName("loginfmt").SendKeys ("xxxx@yyy.com")
obj.FindElementById("idSIButton9").Click
obj.FindElementByName("passwd").SendKeys ("xxxx")
obj.FindElementById("idSIButton9").Click

after auto-typing the password i have an error on the submit button.自动输入密码后,我在提交按钮上出现错误。

Can you help?你能帮我吗?

after login in what would be the code to open a new tab on the same browser?登录后,在同一浏览器上打开新选项卡的代码是什么?

Thank you.谢谢你。

I use the following codes to log in with VBA, and it works.我使用以下代码使用 VBA 登录,并且可以正常工作。

Sub Test()

    Dim obj As New WebDriver  
    
    With obj
        .Start "Chrome"
        .get "https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1594461347&rver=7.0.6738.0&wp=MBI_SSL&wreply=https:%2F%2Faccount.microsoft.com%2Fauth%2Fcomplete-signin%3Fru%3Dhttps%253A%252F%252Faccount.microsoft.com%252F%253Frefd%253Dlogin.live.com%2526ru%253Dhttps%25253A%25252F%25252Faccount.microsoft.com%25252F%25253Frefd%25253Dlogin.live.com&lc=1033&id=292666&lw=1&fl=easi2"
        .FindElementByXPath("//input[@class='form-control ltr_override']").SendKeys ("Your Account")
        .FindElementByXPath("//input[@id='idSIButton9']").Click
        .FindElementByXPath("//input[@class='form-control']").SendKeys ("Your Password")
        .FindElementByXPath("//input[@id='idSIButton9']").Click                 
    End With

    obj.Wait (60000)

End Sub

@Fabio Giallombardo, please let me know if this works for you or not. @Fabio Giallombardo,请告诉我这是否适合您。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM