Selenium Golang绑定无需服务器

huangapple go评论114阅读模式
英文:

Selenium Golang binding without server

问题

有许多用于Golang的Selenium WebDriver绑定包。然而,我不想通过服务器来控制浏览器。

我如何在Golang和Selenium中不使用Selenium服务器来控制浏览器?

英文:

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.

How can I control browser with Golang and selenium without selenium server?

答案1

得分: 3

你可以尝试使用github.com/fedesog/webdriver,它在文档中提到:

> 这是一个纯Go库,不需要运行Selenium驱动程序。

英文:

You can try github.com/fedesog/webdriver which says in its documentation:

> This is a pure go library and doesn't require a running Selenium driver.

答案2

得分: 0

我会将Selenium WebDriver描述为一个客户端而不是一个服务器。注意:我使用的是Selenium WebDriver(Chrome版本),我假设Go语言的使用方式类似。

Selenium的工作方式是,你会在代码中启动一个实例,它会创建一个选定浏览器(比如Chrome)的实时版本,并且你的程序保持对它的控制。然后,你编写代码告诉浏览器导航到一个页面,检查响应,并通过填写表单数据、点击按钮等与浏览器进行交互。在代码运行时,你可以看到浏览器上发生的情况,因此当交互不按计划进行时,很容易进行故障排除。

我曾使用Selenium将数万条记录上传到一个没有API,只有图形用户界面的网站上。给它一个机会吧。

英文:

I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.

The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.

I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

huangapple
  • 本文由 发表于 2015年9月28日 21:00:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/32823643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定