Home>

I am currently creating an automatic operation tool using Selenium in VBA.

This siteI want to automate the operation of, but I have to log in every time.

This articleThen

'[Processing so far]
chromeDriver = New ChromeDriver ()
chromeDriver.Start ()
chromeDriver.Get (url)


To

'[Processing after modification]
chromeDriver = New ChromeDriver ()
'PROFILE_PATH has been declared as a constant
chromeDriver.AddArgument ("user-data-dir ="&PROFILE_PATH)' ← Add
chromeDriver.Start ()
chromeDriver.Get (url)

It says that you can do it by changing it to, but the processing is slightly different and you can not do it.

Below is my code.

      Dim driver As New Selenium.WebDriver
        driver.Start "chrome"
        driver.Get "https://www.furimawatch.net/tool/#!/login"

There wasn't much information, and I couldn't find it when I looked it up.
Please professor!

  • Answer # 1

    How about this?

    Sub test ()
        Dim driver As New Selenium.WebDriver
        UserName = Application.UserName
        PROFILE_PATH = "C: \ Users \" + UserName + "\ AppData \ Local \ Google \ Chrome \ User Data"
        driver.AddArgument ("user-data-dir =" + PROFILE_PATH)
        driver.Start "chrome"
        driver.get "https://www.furimawatch.net/tool/#!/login"
        driver.FindElementByCss ("body>div.container>div>button: nth-child (1)"). Click
        'No longer needed
        'driver.SwitchToNextWindow
         Stop
    End Sub

  • Answer # 2

    chromeDriver.AddArgument ("user-data-dir ="&PROFILE_PATH)' ← Add

    If you don't understand the meaning of, I think it's better to log in every time as it is.

    If you use it without understanding it, you may suddenly stop logging in automatically one day.