在浏览器中使用 Selenium [英] Using Selenium from the browser

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

问题描述

我想从 Web 应用程序运行和控制浏览器窗口,以在另一个站点上自动执行某些操作(例如创建帐户等).

I want to run and control a browser window from a web application, to automate some things (like account creation etc.) on another site.

所以我的问题是,有没有办法直接从浏览器使用 selenium 来做到这一点,在这种情况下怎么做?
我知道有用于 JS 的 selenium-webdriver,但在常见用例中,我们将它与 Node.js 一起使用.

So my question is, is there a way to do it using selenium directly from the browser, and in such a case how to do it?
I know there is selenium-webdriver for JS, but in common use cases we use it with Node.js.

WebDriver 介绍表明这是可能的:

它主要是为了让网络作者编写测试从单独的控制过程自动化用户代理,但可能也可用于允许浏览器内脚本控制— 可能分开 — 浏览器.

It is primarily intended to allow web authors to write tests that automate a user agent from a separate controlling process, but may also be used in such a way as to allow in-browser scripts to control a — possibly separate — browser.

推荐答案

如果你想要做的是:编写一个 WebApp,当它加载到客户端浏览器时,它会在另一个网站上执行一些操作 - 答案是不"- 为了使用 Selenium,你需要一个叫做WebDriver"的东西;这是一个程序"需要在要运行 selenium 的机器上运行(并控制客户端浏览器) - 但不允许从浏览器运行外部程序.

If what you want to do is: write a WebApp in such way that when it is loaded on client browser it does some actions on another website - the answer is "NO" - in order to use Selenium you need a thing called "WebDriver" this is a "program" that needs to be run on the machine where selenium is to be run (and it controls the client browser) - but running external programs from browser is not allowed.

你可以用 selenium 做什么 - 运行webdriver"在特定机器上,并在该机器上的浏览器中控制/自动化操作.

What you can do with selenium - run the "webdriver" on a specific machine, and control/automate actions in a browser on this machine.

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

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