Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Mar 26, 2020 14:26

This section guides you through setting up the integration between Perfecto and NeoLoad for running Selenium/Appium scripts.

Watch this video to see a demo of the integration setup. Detailed steps follow.

On this page:

1 | Set up NeoLoad

  1. Download and install Neoload.
  2. Do one of the following:
    • Import the sample Neoload project or open it if you have already imported it.
    • Create your own project, as follows:
      1. Create a new project.
      2. Create a new user path.

         Click to view image
      3. Insert a new Command line action as a child.

         Click to view image
  3. On Windows only: Install Cygwin and append its bin, normally present under C:\cygwin64\bin, to the environment variables’ PATH variable.
  4. Perform the following based on your platform:
    • On Mac: Add the commands named sh and arg1 as: ${NL-CustomResources}/NL_Shell.sh

       Click to view image
    • On Windows: Set the location of your .sh file into command value. For example, set C:\cygwin64\bin\sh and arg1 as ${NL-CustomResources}\NL_Shell.sh.

       Click to view image
  5. In the custom-resources folder of the NeoLoad project path, create a file called NL_Shell.sh and add the following content:

    cd {MAVEN_PROJECT_PATH}
     
    {MAVEN_PATH}/mvn clean install -Dnl.selenium.proxy.mode=EndUserExperience -Dnl.data.exchange.url=http://localhost:7400/DataExchange/v1/Service.svc/ - Dtestngxml=testng_web_neoload_Desktop_Web_1.xml -Dreportium-job-name=NEOLOAD -Dreportium-job-number=1 -Dreportium_job_tags=demo

    Where:

    • {MAVEN_PROJECT_PATH} should be replaced with the Maven project path.

    • {MAVEN_PATH} should be replaced with the path to the .mvn file.

    • Reporting-related parameters are optional and enable integration with the Perfecto Smart Reporting CI Dashboard.

      Note: For the end-user experience test, the device and number of virtual users should be 1. Make sure that {testngxml} has one device enabled and the project is able to run parallel tests.

      Mac example shell script
      cd /Users/<user-name>/eclipse-workspace/PerfectoNeoLoadJavaMaven
       
      /usr/local/Cellar/maven/3.6.0/bin/mvn clean install -Dtestngxml=testng_web_neoload_Desktop_Web_1.xml -Dreportium_job_name=NeoLoadDemo -Dreportium_job_num=65 -Dreportium_job_tags=demo
      
      Windows example shell script
      #!/bin/bash
       
      cd /cygdrive/c/<<user>>/Workspace/PerfectoNeoLoadJavaMaven
      
      C:/<<user>>/Tools/apache-maven-3.6.3/bin/mvn clean install -Dtestngxml=testng_web_neoload_Desktop_Web_1.xml -Dreportium_job_name=NeoLoadDemo -Dreportium_job_num=65 -Dreportium_job_tags=demo

      Note: If you use Notepad++, make sure to select EOL Conversion to UNIX before saving the above content to NL_Shell.sh

       Click to view image
  6. Create a population and set the desired user path.

     Click to view image
  7. In NeoLoad, select Runtime, set the duration policy to By Iteration, and set both the initial number of users and the maximum number of users to 1 for any load variation policy.

     Click to view image

2 | Integrate NeoLoad with the Maven project

To integrate NeoLoad with the Maven project, you can either use our sample Maven project or your existing Maven framework.

To use the sample project:

  1. Access the project on GitHub: https://github.com/PerfectoCode/Community-Samples/tree/master/PageLoadTimeSampleNeoLoad
  2. In the NeoLoadPerfecto file, update your HOST and SECURITY_TOKEN.

     Click for information on generating a security token

    To generate a security token:

    1. In the Perfecto UI at <YourCloud>.app.perfectomobile.com (where YourCloud is your actual cloud name, such as mobilecloud), click your user name and select My security token

    2. In the My security token form, click Generate Security Token.
    3. Click Copy to clipboard. Then paste it into any scripts that you want to run with Perfecto. 

    4. Click Close.

To use your existing Maven project:

Edit the pom.xml file as follows:

  1. Add repository details to the <repositories> section:

    		<repository>
    			<id>neotys-public-releases</id>
    			<url>http://maven.neotys.com/content/repositories/releases/</url>
    			<releases>
    				<enabled>true</enabled>
    			</releases>
    			<snapshots>
    				<enabled>false</enabled>
    			</snapshots>
    		</repository> 
  2. Add the following Maven dependency:

    	<dependency>
    		<groupId>com.neotys.selenium</groupId>
    		<artifactId>neotys-selenium-proxy</artifactId>
    		<version>2.1.0</version>
    	</dependency> 
  3. In the String variable, add the path to the NeoLoad project, as follows:

    final String projectPath = "/Users/admin/neoload_projects/NewSample/NewSample.nlp";
  4. Create the NL driver and assign the created Perfecto driver instance, as follows:

    this.driver = NLWebDriverFactory.newNLWebDriver(pDriver, "seleniumUserPath", projectPath);

    where: 
                   pDriver is the Perfecto driver with given capabilities (Mobile or Web). 
                   seleniumUserPath is the String variable to retrace results in the NeoLoad controller.
                   projectPath is the Neoload project path to send runtime user experience data.
    NLDriver is an extended Selenium driver provided by NeoLoad with extended methods. The driver fetches runtime user experience data and sends it to the NeoLoad controller via a callback URL.

  5. Call the startTransaction() and stopTransaction() methods of NeoLoad as follows:

    driver.startTransaction("home1");
    driver.get("http://ushahidi.demo.neotys.com/");
    driver.stopTransaction();
    driver.startTransaction("reports");
    driver.findElement(By.id("mainmenu")).findElements(By.tagName("a")).get(1).click();
    driver.stopTransaction();
    

3 | Set up parallel execution

To run tests in parallel, you can create several user paths with different shell files highlighting the testng.xml file (-DtestngXmlFile=testng_web_neoload_Desktop_1.xml), along with different populations. The following sample user paths and populations for executing 3 different testng.xml files run on 3 different platforms in parallel.

 Click to view image

User paths:

 Click to view image

Populations:

 Click to view image

shell.sh:

4 | Execute your tests with NeoLoad Controller

  1. In NeoLoad Controller,
    1. Click Run. NeoLoad triggers the tests in Perfecto.

       Click to view image
    2. Wait for the execution to complete.

       Click to view image
    3. To view platform-related details and load times, click External Data.

       Click to view image
  2. In Perfecto, access the CI Dashboard and individual reports:

     Click to view image
  • No labels