what are the differences (and when to use) selenium-webdriver over webdriverjs?

徘徊边缘 提交于 2021-02-05 13:54:24

问题


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).

Can someone please explain when to use selenium-webdriver over webdriverJs and the benefits?

Thanks!


回答1:


WebDriverJS and selenium-webdriver are both JavaScript bindings for the Webdriver API.

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.




回答2:


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-webdriverjs:

driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.id('btnG')).click();

WD.js

browser
   .get("http://www.google.com")
   .elementById('q')
   .sendKeys('webdriver')
   .elementById('btnG')
   .click()

WebdriverIO:

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.

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);
    });



回答3:


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 -

  • For 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!

  • For 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

Hence the only official Selenium-JavaScript library is selenium-webdriver

Hope this helps!



来源:https://stackoverflow.com/questions/21609040/what-are-the-differences-and-when-to-use-selenium-webdriver-over-webdriverjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!