1

I have created login scripts using hub and nodes.

  • execute command to start selenium server
  • Started a Hub along with selenium server.
  • Started multiple Nodes.
  • Worked on scripts and run for Firefox.

But, what should I do to run login script for concurrent users using multiple browser ?

Kate Paulk
31.5k8 gold badges56 silver badges109 bronze badges
asked Feb 2, 2015 at 9:50
1
  • Try to use TESTNG with XML. Commented Feb 2, 2015 at 12:18

2 Answers 2

3

This load test article is a great walkthru for your scenario - http://www.mkyong.com/unittest/testng-selenium-load-testing-example/

answered Mar 12, 2015 at 11:31
0

You can checkout my sample test automation project for OrangHRM using Selenium

https://github.com/qamate/orangehrm-selenium-automation

Below is my TestNG.xml file

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="smoke-test-suite" parallel="tests" thread-count="5">
<parameter name="ReportLocation" value="reports"></parameter>
<parameter name="remoteURL" value="http://localhost:4444/wd/hub"></parameter>
<!-- <parameter name="baseURL" value="http://opensource.demo.orangehrmlive.com/"></parameter> -->
 <parameter name="baseURL" value="http://www.google.com/"></parameter>
 <parameter name="internal" value="false"></parameter>
 <!--
 <test name="test_ff" >
 <parameter name="OS" value="WIN8_1"></parameter>
 <parameter name="browser" value="firefox"></parameter>
 <parameter name="version" value="34"></parameter>
 <classes>
 <class name="com.qamate.orangehrm_selenium_automation.Tests.LoginTest" >
 </class>
 </classes>
 </test>
 <test name="test_ie" >
 <parameter name="OS" value="WIN8_1"></parameter>
 <parameter name="browser" value="internet explorer"></parameter>
 <parameter name="version" value="34"></parameter>
 <classes>
 <class name="com.qamate.orangehrm_selenium_automation.Tests.LoginTest" >
 </class>
 </classes>
 </test>
 <test name="test_chrome" >
 <parameter name="OS" value="WINDOWS"></parameter>
 <parameter name="browser" value="chrome"></parameter>
 <parameter name="version" value="ANY"></parameter>
 <classes>
 <class name="com.qamate.orangehrm_selenium_automation.Tests.LoginTest" >
 </class>
 </classes>
 </test>-->
 <test name="test_chrome" >
 <parameter name="OS" value="WINDOWS"></parameter>
 <parameter name="browser" value="chrome"></parameter>
 <parameter name="version" value="ANY"></parameter>
 <classes>
 <class name="com.qamate.orangehrm_selenium_automation.Tests.GoogleTest" >
 </class>
 </classes>
 </test>
<!--
 <test name="reportingTest" >
 <classes>
 <class name="com.kagrana.base.BaseActionsTest" >
 </class>
 </classes>
 </test>
 <test name="reportingTest1" >
 <classes>
 <class name="com.kagrana.base.BaseActionsTest1" >
 </class>
 </classes>
 </test>
 <test name="reportingTest2" >
 <classes>
 <class name="com.kagrana.base.BaseActionsTest2" >
 </class>
 </classes>
 </test>
 <test name="reportingTest3" >
 <classes>
 <class name="com.kagrana.base.BaseActionsTest3" >
 </class>
 </classes>
 </test>
 <test name="reportingTest4" >
 <classes>
 <class name="com.kagrana.base.BaseActionsTest4" >
 </class>
 </classes>
 </test>
 -->
</suite>

In the above example, you can see the way I am specifying different browser combinations for different tests as parameters. From your test class you can read these parameters.

E.g. See below class file.

package in.mayurshah.base;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import in.mayurshah.DTO.WebDriverConfig;
import in.mayurshah.util.Log;
import org.openqa.selenium.WebDriver;
import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import in.mayurshah.DTO.TestCase;
public abstract class BaseActions {
 protected WebDriver driver;
 protected static Log log;
 protected WebDriverConfig config;
 protected String baseURL;
 protected TestCase testCase;
 private static int testCaseCount = 1;
 /**
 * This gets invoked even before suite starts.
 * @param ReportLocation - Provide location where you want to store the report
 */
 @Parameters({"ReportLocation"})
 @BeforeSuite
 public void beforeSuite(@Optional String ReportLocation){
 log = new Log();
 log.setReportDirectory(ReportLocation);
 }
 @BeforeMethod
 @Parameters({ "remoteURL", "baseURL", "OS", "browser",
 "version", "internal" })
 public void beforeTest(String remoteURL, String baseURL,
 String OS, String browser, String version, String internal)
 throws IOException {
 this.testCase = new TestCase();
 this.testCase.setExecutionEnvironment("{browser:"+browser+",browserVersion:"+version+",OperatingSystem:"+OS+"}");
 this.testCase.setParentURL(baseURL);
 this.testCase.setTestCaseId("KT"+testCaseCount++);
 this.testCase.setScreenshotDirectory(log.getReportDirectory()+"\\images");
 config = new WebDriverConfig();
 config.setRemoteURL(remoteURL);
 this.baseURL = baseURL;
 config.setOS(OS);
 config.setBrowserName(browser);
 config.setBrowserVersion(version);
 config.setIntenal(Boolean.parseBoolean(internal));
 driver = xRemoteWebDriver.getInstance(config, log);
 driver.manage().window().maximize();
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 driver.get(this.baseURL);
 }
 @AfterMethod
 public void afterTest(ITestResult itr) {
 testCase.setExecutionTime((itr.getEndMillis() - itr.getStartMillis()));
 testCase.setTestCaseName(itr.getName());
 log.addTestCase(testCase);
 try {
 driver.close();
 } catch (Exception ignore) {
 }
 try {
 driver.quit();
 } catch (Exception ignore) {
 }
 }
 @AfterSuite
 public void afterSuite(ITestContext itc) throws IOException{
 log.setTestSuiteName(itc.getSuite().getName());
 log.writeReport();
 log.zipAndEmailFile();
 }
}

Hope that helps!

answered Feb 10, 2015 at 6:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.