How can I run test cases in parallel using Keyword Driven Framework

0 votes
Hi All,

I'm using Keyword Driven Framework.

I've 3 classes

1.@Test method to run the tests
2.Driver Script to maintain all Keywords related conditions
3.FUnction Library to maintain all actionMethods and Functional related methods. Ex : EnterText,SelectDropDowns

Maintaining steps in Excel sheets with Test Case wise.

Script will run ,By Making TC number status as "Y",If "N" in master test cases sheet ,nothing will execute

Can any one provide ,how to run Multiple Tests parallely By making multiple tests as "Y" Ex : 5 test cases.
Jun 9, 2020 in Selenium by Rajesh
• 120 points
2,867 views

1 answer to this question.

0 votes

One solution to try for executing test cases in parallel using a keyword driven framework can be :

  1. Have a master sheet of cases to execute, which acts as your suite.
  2. Have your dataprovider read this master sheet and have a single @Test method which takes in the arguments of the testcase data. This testcase basically reads the steps and executes - something like your ReadAnExecureTestCase method.
  3. Make this dataprovider parallel and control using dataprovider thread count.
answered Jun 29, 2020 by Alexander
Can you please provide the code becasue same answer i've seen in Stackoverflow,they have not given any clear examples.

Hey could you try something like this:

public class DriverScript {

List<String> testcase;

@Factory(dataProvider = "testCases")
public DriverScript(List<String> testcase) {
    this.testcase = testcase;
}


@Test
public void runTestCase() {
  // change this method run single with List<String>. Previously you passed  List<List<String>> 
  DriverScript.prepareKeywords(testcase);
}

@DataProvider
public Object[][] testCases(ITestContext context) throws InterruptedException {
    excelUtilities eu = new excelUtilities();

    Properties gldata = new Properties();
    InputStream input = new FileInputStream("src/executionEngine/config.properties");
    gldata.load(input);

    List<List<String>> testcases = new ArrayList<List<String>>();
    testcases = eu.getTestCases(gldata.getProperty("WB_PATH_TESTS"), gldata.getProperty("WB_PATH_TESTS_SHEET"));

    List<List<String>> testcases = new ArrayList<>();
    Object[][] testCasedata= new Object[testcases.size()][1];
    for (int i = 0; i < testcases.size() ; i++) {
        testCasedata[i][0]=testcases.get(i); 
    }
    return testCasedata;
}

To run the above test with parallel=instances, we have to create testuite xml like below and run testng using this xml suite,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="KeywordDrivenSuite" thread-count="2" parallel="instances"
    preserve-order="true" configfailurepolicy="continue">
    <test name="KeywordDrivenTest">
        <classes>
            <class
                name="com.package.DriverScript" />
        </classes>
    </test>
</suite>

Hi ,i tried the same code but facing problem at dataprovider method,it is not reading the data getting nullpointer exception.

can you please provide "eu.getTestCases" method code.
Hey could you please post the error you are getting?
Hey Hi..

I am facing a similar challenge. I want to pick the test case keywords from testdata excel sheet and carry on the parallel testing. Currently there is only a single @ test method. If you have achieved this. Can you please help me know how you did it?

Thanks in advance!
Hey, have you tried the workarounds as suggested above?

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 28,140 points
1,977 views
0 votes
1 answer
0 votes
1 answer

How to run a group of test cases using TestNG in Selenium Webdriver?

Hey Kajal, TestNG allows you to perform ordered ...READ MORE

answered Jun 12, 2019 in Selenium by Abha
• 28,140 points
2,930 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,690 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,151 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,230 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,881 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP