在 Selenium VBA 中使用 Google Chrome(安装步骤) [英] Using Google Chrome in Selenium VBA (Installation Steps)

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

问题描述

我什至在为 VBA 设置 Selenium 时遇到问题.我一直在网上阅读该做什么,下载 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 相同的方式使用谷歌浏览器.我将不胜感激任何有关设置 selenium 的帮助,我知道我的问题可能被视为愚蠢.

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 steps 1- 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- 从 链接

3- 从以下 LINK 下载 chromedriver确定适合您的 chrome 版本的版本至于 Google Chrome 版本,我贴出的最合适的 chromedriver 版本是 ChromeDriver 75.0.3770.140

3- Download the chromedriver from the follwoing LINK Make sure of the version that suits your chrome version As 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 FilesSeleniumBasic第二 >> C:Users\%username%AppDataLocalSeleniumBasic将 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 selenium Here's two possibilties: First >> C:Program FilesSeleniumBasic Second >> C:Users\%username%AppDataLocalSeleniumBasic Copy the chromedriver.exe to the SeleniumBasic path

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

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(安装步骤)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆