使用Selenium的Excel VBA [英] Excel VBA using Selenium

查看:119
本文介绍了使用Selenium的Excel VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Windows 10.我正在尝试使用Selenium通过Excel VBA自动化Edge浏览器(或任何其他浏览器).

I am om Windows 10. I am trying to use Selenium to automate the Edge browser (or any other browser) via Excel VBA.

我去了 https://www.selenium.dev/downloads/

我在那里下载了Selenium Server,最新的稳定版本3.141.59和Python 3.141.0 2018年11月1日4.0.0a6.post1 2020年5月28日下载(我不使用Python,但我想将来会使用.)

There I downloaded Selenium Server, Latest stable version 3.141.59 and Python 3.141.0 November 01, 2018 4.0.0a6.post1 May 28, 2020 Download (I am not using Python but I thought I might in the future.)

然后我打开Excel VBA并打开了Tools,但是在下拉菜单中找不到"Selenium Type Library"选项.

Then I opened Excel VBA and opened Tools but could not find the "Selenium Type Library" option in the drop down.

我做了更多的阅读,并在以下位置下载了SeleniumBasic https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0

I did more reading and I downloaded SeleniumBasic at https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0

这使硒类型库"选项出现在工具"下拉列表中.

This made the option "Selenium Type Library" appear on the Tools dropdown.

我选择了硒类型库"选项.

I selected the "Selenium Type Library" option.

我在网上发布的VBA编辑器中输入了此代码.它会打开Chrome(找不到打开Edge的语法).

I entered this code in the VBA editor, which I got off the web. It opens Chrome (could not find the syntax to open Edge).

Sub test2()

    Dim driver As New WebDriver
    Dim rowc, cc, columnC As Integer
    driver.Start "Chrome"
    Application.Wait Now + TimeValue("00:00:20")

End Sub

失败.它在网上轰炸了:

It failed. It bombed out on the line:

driver.Start "Chrome"

它给出了一个错误:来自未知错误的异常"

It gave an error: "Exception from unknown error"

我完全不知道该怎么办.帮助!

I am totally lost on what to do. Help!

不胜感激!

推荐答案

您是否已安装硒铬驱动程序?这是必需的,并且与服务器和Visual库不同.这是将启动并运行的实际Chrome二进制文件.下载最新版本,并将其放置在基本访问权限的路径中它.我相信路径是 C:\ Users \ * Username \ AppData \ Local \ SeleniumBasic

Do you have the selenium chromium driver installed? That is required and it is different than the server and Visual library. This is the actual chrome binary that will launch and run. Download the latest version and place it in path such that basic can access it. I believe the path is C:\Users\ *Username\AppData\Local\SeleniumBasic

可执行文件也应该是小写字母:

The executable should also be lowercase:

Dim driver As New WebDriver 
driver.Start "chrome" 
driver.Get "https://duckduckgo.com" 

这篇关于使用Selenium的Excel VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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