使用 VB.net 设置 Selenium
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23091482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting up Selenium with VB.net
提问by Mrk Fldig
Really basic question here but for some reason I can't find a VB.NET tutorial. I've used selenium on a load of other projects in ruby so this is really bugging me!
这里非常基本的问题,但由于某种原因,我找不到 VB.NET 教程。我已经在 ruby 中的许多其他项目中使用了 selenium,所以这真的让我很烦恼!
I've downloaded selenium-dot-net from google code, i've also downloaded the IEDriver.exe how do I instantiate the driver in vb code?
我已经从谷歌代码下载了 selenium-dot-net,我还下载了 IEDriver.exe 如何在 vb 代码中实例化驱动程序?
Thanks
谢谢
Marc
马克
Edit
编辑
To be clear i've imported webdriver.support.dll and webdriver.dll and the code so far looks like(this throws an error saying the service isnt running which is fair enough since I haven't started iedriver.exe)
需要明确的是,我已经导入了 webdriver.support.dll 和 webdriver.dll,到目前为止的代码看起来像(这会抛出一个错误,说服务没有运行,这很公平,因为我还没有启动 iedriver.exe)
Imports OpenQA.Selenium.IE
Imports OpenQA.Selenium
Imports OpenQA.Selenium.Support.UI
Public Class SearchForm
Private Sub SearchForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim mydriver as new InternetExplorerDriver
End Sub
采纳答案by Mrk Fldig
Ok simple way to do this:
好的简单的方法来做到这一点:
You need to download the driver for the browser you want to work with from the selenium website. Download, extract and keep a note of the path you extracted it to.
您需要从 selenium 网站下载要使用的浏览器的驱动程序。下载、解压并记下解压到的路径。
Then in your code:
然后在你的代码中:
Dim mydriver As New ChromeDriver("C:\Users\Marc\Downloads\chromedriver_win32")
Thats it, you now have access to all the Selenium you need!
就是这样,您现在可以访问您需要的所有 Selenium!

