Both selenium-webdriver and WebdriverIO perform similar functions, but differ in their approach to writing tests. selenium-webdriver utilizes a mixture of promises and callbacks, while WebdriverIO solely relies on promises and can function either independently or with an internal testrunner. Additionally, there is another library known as wd.js. Below are examples showcasing the usage of 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')
WebdriverIO emphasizes wrapping protocol commands into user-friendly action commands, though it also covers almost all protocol commands for standard JSONWire protocol implementation.
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);
});