本文介绍了在Selenium VBA中使用Google Chrome(安装步骤)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我甚至在为VBA设置Selenium时遇到问题.我一直在网上阅读有关该怎么做的信息,请下载硒( https: //github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0 )添加扩展名等.但是,我仍在努力使其工作.

I am having problems even setting up Selenium for VBA. I have been reading online on what to do, download the selenium (https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0) add extension and etc. However, I am still struggling to get it to work.

即使编写类似于以下在网上找到的简单代码:

Even writing a simple code like the following which I have found online:

Public Sub Demo()
    Dim d As WebDriver
    Set d = New ChromeDriver
    Const URL = "https://www.google.com/"

    With d
        .Start "Chrome"
        .get URL
        .FindElementById("lst-ib").SendKeys "Selenium basic GitHub"
         .FindElementsByTag("form")(1).FindElementByCss("input[value='Google Search']").Click
        '.Quit
    End With
End Sub

给我一​​个自动化错误.

Gives me an Automation error.

我想以与Internet Explorer相同的方式使用google chrome.我非常感谢您对设置硒的帮助,而且我知道我的问题可以说是愚蠢的.

I would like to use google chrome in the same way as internet explorer.I would appreciate any help with setting up selenium , and I know my question can be seen as silly.

推荐答案

首先,转到控制面板并卸载先前安装的selenium,然后按照以下步骤进行操作1-下载最新版本的chrome,并从帮助>>关于Google Chrome中确定Chrome的版本.您会看到类似Version 75.0.3770.142 (Official Build) (32-bit)

First of all, go to control panel and uninstall previous installation of selenium and then follow the steps1- Download the latest version of chrome and make sure of the version of Chrome from Help >> About Google Chrome. You would see something like that Version 75.0.3770.142 (Official Build) (32-bit)

2-从 LINK

3-从以下 LINK 下载chromedriver确保适合您的Chrome版本至于Google Chrome版本,我发布的chromedriver最合适的版本是ChromeDriver 75.0.3770.140

3- Download the chromedriver from the follwoing LINKMake sure of the version that suits your chrome versionAs for the Google Chrome version I posted the most suitable version of chromedriver is ChromeDriver 75.0.3770.140

  1. 现在设置SeleniumBasic >>设置完成后,解压缩chromedriver文件chromedriver_win32.zip,然后将chromedriver.exe复制到selenium的路径中这有两个可能性:首先>> C:\Program Files\SeleniumBasic第二>> C:\Users\%username%\AppData\Local\SeleniumBasic将chromedriver.exe复制到SeleniumBasic路径

  1. Now setup SeleniumBasic >> After setup unzip the chromedriver file chromedriver_win32.zip and copy the chromedriver.exe to the path of seleniumHere's two possibilties: First >> C:\Program Files\SeleniumBasicSecond >> C:\Users\%username%\AppData\Local\SeleniumBasicCopy the chromedriver.exe to the SeleniumBasic path

打开新的空白excel文件>>按Alt + F11(Visual Basic编辑器)>>工具>>参考>> Selenium Type Library

Open new blank excel file >> Press Alt + F11 (Visual Basic Editor) >> Tools >> References >> Selenium Type Library

插入新模块并粘贴以下代码进行测试

Insert new module and paste the following code to test

Sub Test()
    Dim bot         As New WebDriver

    bot.Start "chrome", "https://www.google.com"
    bot.Get "/"
    Stop
End Sub

这篇关于在Selenium VBA中使用Google Chrome(安装步骤)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:49