WebDriverIO Version 5 vs Version 4 Differences

I used webdriverIO library in my programming. Recently I upgraded from version 4 to version 5. To my horror so many breaking changes and not much explanation on the internet. So I put some difference on it.

WebDriveIO – Version 4

  const options = {
    desiredCapabilities: {
        browserName: 'firefox'
    }
  };

  const browser = webdriverio.remote(options);
  await browser.init();

  const select = "a";
  const attribute = "href";

  let results = await browser.getAttribute(selector, attribute);
  results = await browser.getHTML(selector);

WebDriverIO – Version 5

const options = {
    capabilities: {
        browserName: 'firefox'
    }
  };

  const browser = await webdriverio.remote(options);


  const select = "a";
  const attribute = "href";

  let elements = await browser.$(selector);
  let results = await elements.getAttribute(attribute);

  elements = await browser.$(selector);
  results = await elements.getHTML(selector);

The Difference

  1.  In version 5, options desiredCapabilities change to capabilities
  2.  In version 5, need to put await in remote and no need to declare init() anymore as it is deprecated.
  3. In version 5, use $(selector) to select elements before getting elements content or attribute.

Reference

Breaking Change WebDriverIO from Version 4 to Version 5

WebDriver version 5 Release Announcement