Chai JS Assertions - WebdriverIO Tutorial | #6

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 12

  • @suranjanbanerjee8639
    @suranjanbanerjee8639 2 роки тому +1

    Thank you sir, you explained it so well....

    • @sdetunicorns
      @sdetunicorns  Рік тому

      Glad you enjoyed the content. We have created multiple courses that takes our students from ground level. If you want to become a full stack Automation engineer, Please check out the academy at: sdetunicorns.com/courses/

  • @playandfun7446
    @playandfun7446 4 роки тому +1

    Hi,
    I made this changes in my wdio.conf.js so that chai assertion can be assessed from anywhere without importing it. May be it can help others.
    -----------
    beforeTest: function () {
    const chai = require("chai");
    const chaiWebdriver = require("chai-webdriverio").default;
    chai.use(chaiWebdriver(browser));
    global.chaiAssert = chai.assert;
    global.chaiShould = chai.should;
    global.chaiExpect = chai.expect;
    },
    ------------------------

    • @sdetunicorns
      @sdetunicorns  4 роки тому

      Yes, this takes away the pain of importing it everywhere. Thanks for commenting!

  • @atuljadhav5566
    @atuljadhav5566 2 роки тому

    Hi Dilpreet, I am still facing an issue with script run. I have setup the configuration and chai assertation and babel. I have also added require: ['@babel/register'] in config file but I am getting below error. Could you please suggest the possible root cause of this?
    import { expect as chaiExpect } from 'chai';
    [0-0] ^^^^^^
    [0-0]
    [0-0] SyntaxError: Cannot use import statement outside a module

    • @sdetunicorns
      @sdetunicorns  2 роки тому

      You will need to install all the babel packages as well. Take a look at this - webdriver.io/docs/babel/

  • @pankajpatil9232
    @pankajpatil9232 3 роки тому

    If I want to print my own error message if assertion fails.. then is there any way.. something like assert(expected, actual, error message) ?

    • @sdetunicorns
      @sdetunicorns  3 роки тому

      Most of the default assertions with WebdriverIO has options to add your own error message. You can take a look at an example here - webdriver.io/docs/api/expect-webdriverio#tohaveelementclass

  • @ushad2263
    @ushad2263 4 роки тому

    Hi , How do I continue tests execution after assertion fails. Do we have something like soft assertion ( Selenium webdriver) in webdriverio?

    • @sdetunicorns
      @sdetunicorns  4 роки тому +1

      No, WebdriverIO does not support soft assertions and is also not recommended. If you still need it, you can wrap the code around try/catch.