javascript selenium-webdriver 与 webdriverjs 有什么区别(以及何时使用)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21609040/
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
what are the differences (and when to use) selenium-webdriver over webdriverjs?
提问by Major
I'm an experience professional that uses selenium-webdriver. I'm exploring more options on how to test javascript applications and I found webdriverJs. Unfortunately, I dont understand what's the difference between these two (2).
我是使用 selenium-webdriver 的经验专家。我正在探索更多关于如何测试 javascript 应用程序的选项,我发现了 webdriverJs。不幸的是,我不明白这两个(2)之间有什么区别。
Can someone please explain when to use selenium-webdriver over webdriverJs and the benefits?
有人可以解释一下什么时候在 webdriverJs 上使用 selenium-webdriver 以及它的好处吗?
Thanks!
谢谢!
采纳答案by ddavison
WebDriverJS and selenium-webdriver are both JavaScript bindings for the Webdriver API.
WebDriverJS 和 selenium-webdriver 都是 Webdriver API 的 JavaScript 绑定。
The only difference is that selenium-webdriver is the official implementation maintained by the selenium team, whereas WebDriverJS is not. WebDriverJS is maintained by a third-party.
唯一的区别是 selenium-webdriver 是 selenium 团队维护的官方实现,而 WebDriverJS 不是。WebDriverJS 由第三方维护。
回答by ChristianB
They do basically the same thing. The main difference is how you write your tests. selenium-webdriver is a mix of promises and callbacks - WebdriverIO only works with promises and can be used as standalone or with an internal testrunner. There is also a library called wd.js. Here is an example of how all three flavors.
他们基本上做同样的事情。主要区别在于您如何编写测试。selenium-webdriver 是 Promise 和回调的混合体 - WebdriverIO 仅适用于 Promise 并且可以独立使用或与内部测试运行器一起使用。还有一个名为 wd.js 的库。这是所有三种口味的示例。
selenium-webdriverjs:
硒-webdriverjs:
driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.id('btnG')).click();
WD.js
WD.js
browser
.get("http://www.google.com")
.elementById('q')
.sendKeys('webdriver')
.elementById('btnG')
.click()
browser
.url('http://google.com')
.setValue('#q','webdriver')
.click('#btnG')
WebdriverIOs concept is to wrap all protocol commands in handy action commands but it has also almost all protocol commands implemented, so you can do the same with the standard JSONWire protocol commands.
WebdriverIOs 的概念是将所有协议命令包装在方便的操作命令中,但它也实现了几乎所有协议命令,因此您可以对标准 JSONWire 协议命令执行相同操作。
browser
.url('http://google.com')
.element('#q').then(function(res) {
return browser.elementIdValue(res.value.ELEMENT, 'webdriver');
})
.element('#btnG').then(function(res) {
return browser.elementIdClick(res.value.ELEMENT);
});
回答by chimi
I read the official documentation of NPM and seems that the 'accepted' answer on this thread is now incorrect ( It is possible that at the time of the original post the answer was correct ). You can review the official NPM document -
我阅读了 NPM 的官方文档,似乎该线程上的“已接受”答案现在不正确(在原始帖子发布时,答案可能是正确的)。你可以查看 NPM 官方文档——
- For WebDriverJS => https://www.npmjs.com/package/webdriverjs
- 对于 WebDriverJS => https://www.npmjs.com/package/webdriverjs
The document says -
文件说——
Project is now called WebdriverIO and has moved to webdriverio/webdriverio on GitHub. Please use $ npm install webdriverio because this NPM project is not maintained anymore!
项目现在称为 WebdriverIO,并已移至 GitHub 上的 webdriverio/webdriverio。请使用 $ npm install webdriverio 因为此 NPM 项目不再维护!
- For selenium-webdriverjs => https://www.npmjs.com/package/selenium-webdriverjs
- 对于 selenium-webdriverjs => https://www.npmjs.com/package/selenium-webdriverjs
The document says -
文件说——
This package has been deprecated. Author message: End of life. Upstream has released an official package: selenium-webdriver
该软件包已被弃用。作者信息:生命尽头。上游已经发布了一个官方包:selenium-webdriver
Hence the only official Selenium-JavaScript libraryis selenium-webdriver
因此,唯一的官方 Selenium-JavaScript 库是selenium-webdriver
Hope this helps!
希望这可以帮助!