<<Previous Post << Complete Tutorial>> Next Post>>
WebDriverIO – Skip Test Cases in WebDriverIO
It.skip command is used to Skip test cases from n number of test cases present in describe block.
Syntax: – It.skip
Pre-requisite: Have ‘Visual Studio Code’ IDE installed in your machine (Click here to install if not installed in your machine)
Skip Test Cases in WebDriverIO
In This Article we will use same code base which is present in our WebDriverIO-Using Xpath Locators and append our command i.e., “it.skip” to skip one of the test case out of two test cases present in describe block.
Note: – “It.skip” can be used to skip any number of test cases present in describe block.
Pre-requisite: Download the Project from here (Click here to Download) and Unzip it.
Practical Demonstration:
1) Open Visual Studio Code on your system.
2) Click on File and Select Open Folder. Select the project folder on which your workspace is present.
3) Expand ‘test’ from the Explorer, right click on the displayed ‘specs’ and select ‘New File’ option as shown below:
4) Give any name of the newly created file say “skip_testcase_test.js” and copy the below given code into the newly created file as shown below and save the file:
The following is the WebDriverIO sample code for skipping one test cases out of two test cases present in describe block. You can understand this code, by reading the comments provided in the below code:
Copy the code from here:-
describe('Explaining how to skip test cases in WebDriverIO',() => { it.skip('should skip this test case',() => { browser.url ('http://omayo.blogspot.com') $('/html/body/div[4]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[3]/div/asid e/div[1]/div[4]/div[1]/input').click() browser.pause(3000); }); It ('should find Relative Xpath for ClickToGetAlert Button and Then click on it',() => { browser.url('http://omayo.blogspot.com') $('//*[@id="alert1"]').click() browser.pause(3000); }); });
5) Click on ‘wdio.conf.js’ to open in the IDE, and make sure the Test file name is updated properly in this file as shown below and save it:
6) Click on Terminal and Open New Terminal.
7) By Default, Powershell Terminal will open as shown below:
8) Run geckodriver.exe in the Powershell terminal as shown below to run Geckodriver in background.
9) Open Another Terminal in the same way we did in the step 6 and run below command in terminal
.\node_modules\.bin\wdio .\wdio.conf.js
Observe that the ‘skip_testcase_test.js’ will get executed successfully, the Firefox Browser will launch and respective action will be taken by WebDriverIO Automation code.
And also, the result will be displayed as ‘Passed’ in the terminal as shown below:
This is how, we can take help of It.skip Command of WebDriverIO to skip one of the test case out of two test cases present in describe block. , and I will explain other commands to perform different operations on WebPages using WebDriverIO in the upcoming Articles.
Next Steps:
> To learn more about WebDriverIO, continue to the next post (Click on Next Post link below)
> Check complete WebDriverIO Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?
Connect to me on LinkedIn (Click here)
On a mission to contribute to the Software Testing Community in all possible ways.
<<Previous Post << Complete Tutorial>> Next Post>>
Hi Ajay Lunia. I have the question, Do you know away the skip test “it” specific from a wdio.config file? I want skip for production environment but no skipt tests for test environment. Thanks for all!!