When should you opt for selenium-webdriver instead of webdriverjs and what sets them apart?

Hello, I am well-versed in using selenium-webdriver and have recently come across webdriverJs while looking for alternative options to test javascript applications. However, I am unsure about the distinctions between these two tools.

I would greatly appreciate it if someone could clarify when it is preferable to use selenium-webdriver instead of webdriverJs and outline the advantages of each.

Thank you in advance!

Answer №1

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

Answer №2

WebDriverJS and selenium-webdriver serve as JavaScript interfaces to the Webdriver API.

The key distinction lies in selenium-webdriver being the endorsed version supported by the selenium team, while WebDriverJS is developed by an external entity.

Answer №3

After carefully reviewing the official NPM documentation, it has come to my attention that the previously 'accepted' answer on this thread is now outdated (although it may have been correct at the time of posting). For accurate information, please refer to the official NPM document -

The documentation clearly states -

The project is now known as WebdriverIO and has relocated to webdriverio/webdriverio on GitHub. To install, please use $ npm install webdriverio as the original NPM project is no longer maintained!

The official notice reads -

This package has been marked as deprecated. The author's message indicates: End of life. An official replacement has been released by the upstream: selenium-webdriver

Therefore, the only validated Selenium-JavaScript library can be found at selenium-webdriver

I hope this clarifies any confusion!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing AJAX and PHP to create a dynamic like button function

Is there a way to make the like number increase without refreshing the page when the like button is clicked? Here's my current code: <script type="text/javascript> jQuery(document).ready(function ($) { $('body').on( 'cli ...

An easy guide to rerouting a 404 path back to the Home page using Vue Router in Vue.js 3

Hello amazing community! I'm facing a small challenge with Vue.js 3. I am having trouble setting up a redirect for any unknown route to "/" in the router. const routes = [ { path: "/", name: "Home", component: Home, }, { path: "* ...

Using AngularJS location.path for unique custom URLs

Control Code: $scope.$on('$locationChangeStart', function () { var path = $location.path(); var adminPath = '/admin/' ; if(path.match(adminPath)) { $scope.adminContainer= function() { return true; }; }); HTML <div clas ...

Are SVGs with JavaScript for parallax effects?

Recently, I stumbled upon a webpage that left me in awe (Link Below). It seems to combine parallax effects with dynamic information that appears on screen as the user interacts with different elements. Despite my attempts to find more information about thi ...

Angular: Design dependent on attributes

Can I customize the styling of a div in accordance with a boolean property called "isActive" on my controller using Angular? <div class="col-md-3" (click)="isActive = !isActive"> <div class="center"> <i class="fa fa-calendar"& ...

Frosted and see-through circular background effect triggered by mouse movement

I've been attempting to duplicate the mesmerizing effect showcased on this webpage: (give it a try by moving your mouse), but I'm baffled by how they managed to achieve it? My attempts at experimenting with a JSFiddle can be found here: http:// ...

Encountering a problem when trying to find an element with xpath in Selenium 3

I am encountering an issue while attempting to click on a link that resembles a tab button using Xpath. Here is the snippet of html: <div id="tile_8" style="height: 93px; width: 26%; background-color: rgb(45, 87, 19); color: white; position: relativ ...

Tips for adjusting the dimensions of my chart using JavaScript or Jquery

Utilizing DevExtreme widgets for the creation of a line chart in jQuery as shown below: var dataSource = [{"Date Range": "August-2018", Benelux: 194, Czech_Slovakia: 128, ...

Issues with parsing XML data when using the xml2js library

I am looking to extract and populate values from a large XML dataset into a mySQL table. The XML data structure is as follows: <BMS version="1.0"> <Summaries> <Summary Booking_strId="CWBL00D7CB8J8U" Booking_lngId="466244159" Trans_lngId="4 ...

What could be causing me to receive null when trying to retrieve an element with document.getElementById, even after invoking $(document).ready(function() { ... })?

Here's a small example. I'm feeling a bit rusty with JavaScript, as it's been some time since I last worked with it. The problem I'm encountering is an error in Chrome developer tools: "Uncaught TypeError: Cannot set property 'src ...

Does the PHP include function act as an HTTP request?

After coming across an article highlighting the negative impact of using excessive HTTP requests on server speed, I started wondering about the performance implications of PHP includes. Specifically, I'm curious if sending 4 AJAX requests compared to ...

Tips on customizing the color of checkboxes in a ReactJS material table

I'm working on a project that involves using the Material table, and I need to change the color of the checkbox when it's selected. Can anyone help me with this? https://i.stack.imgur.com/JqVOU.png function BasicSelection() { return ( <M ...

Error: Angular does not recognize session storage reference

While my project is up and running, I have encountered an error in the terminal. let obj = { doc_id: sessionStorage.getItem('doc_id'), batch_no: sessionStorage.getItem('batch_no') } I attempted to make adjustments by a ...

What is the best way to deactivate certain JavaScript functions on my webpage when accessed through a mobile device?

Is there a way to disable specific JavaScript functions when accessing my website from a mobile device? While I can achieve this using CSS only, certain buttons require JavaScript functionality. Below is the internal JavaScript code: var menuBtn = docume ...

Mouseover function not triggering until clicked on in Google Chrome

I'm attempting to execute a function when the cursor hovers over a list item as shown below: <div id="vue-app"> <ul> <li v-for="item in items" @mouseover="removeItem(item)">{{item}}</li> </ul> </div> ...

What is the best way to utilize Selenium Webdriver with headless Chrome?

Currently, I am diving into the world of Selenium to explore its capabilities in tasks like capturing screenshots, web scraping, and testing. I am particularly interested in using it with headless Chrome, which has now been stable since Chrome version 59. ...

Protecting a javascript string in php: A comprehensive guide

Having trouble with my PHP javascript string. Attempted to add a string to a variable within a switch statement but encountered an error: $blocPub = '<script type="text/javascript"> var rdads=new String(Math.random()).substring (2, 11 ...

Choose a date in the upcoming days using the Selenium date picker function

I'm grappling with the task of choosing a future date using a date picker, but I'm struggling to figure out the approach. The challenge is that I need to select a date that is 14 days ahead, yet the date picker only displays one calendar month a ...

Learn the steps to send an email using CodeIgniter and troubleshoot any errors present in the provided code

<?php class Greetings extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('email'); // loading the email library } function display() { ...

Is there a way for me to write on a website and have my content instantly show up on a different hosting

Similar Question: Web based text chat? I am looking to develop a website that enables me to type in a textbox and have the content displayed on another user's screen. Can anyone assist me with this task? Thank you! Amen ...