Uncategorized

Reading Time: 1 minute

During UI test automation you will need to write tests that validate the options that are present in a select tag.
Getting all the options in the select tag is very simple using Selenium Webdriver and below is how it is done.

1. In the page object model of the page you create a WebElement that identifies the select tag; example class presented below:


import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;


public class PageObject {

public String[] occupantNoOptionExpectedArray = {"1", "2", "3", "4", "5+"};

@FindBy(xpath = "//select[@id='numberofoccupants']")
public WebElement noOfOccupantsDropdown;

}

2. In the test you will create a Select object (class org.openqa.selenium.support.ui.Select) like in the below example:


import java.util.List;


import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import org.testng.annotations.Test;

public class OccupantPageTest {

PageObject pageObject = new PageObject();
[emaillocker]
@Test
public void test_Occupants_Drop_Down_Values() throws Exception{
Select selectBedroom = new Select(pageObject.noOfOccupantsDropdown);
List<WebElement> optionSelect = selectBedroom.getOptions();

for (int i = 0; i < optionSelect.size(); i++){
Assert.assertEquals(optionSelect.get(i).getText(), pageObject.occupantNoOptionExpectedArray[i], "Values in the drop down for number of occupants are wrong"  );
}
}
}

That’s it. Simple. Enjoy.
[/emaillocker]

Uncategorized

Reading Time: 2 minutes

In order to extract data from the response with JMeter you need to:

  • have the CSV file with the credentials in a format similar to the one below
  • have JMeter installed
  • JMeterPlugins-Extras installed – installing the plugins is detailed on the following post
  • JMeterPlugins-ExtrasLibs installed – installing the plugins is described on the following post

Four steps from the CSV file to being able to login and getting the token from the response

1. The CSV file with the credentials

The CSV file that we will use as the source(username and password) for the login process needs to be in a format similar to the following:


user1,password1
user2,password2
user3,password3
user4,password4
user5,password5

2. Create a new thread group and add the CSV Data Set Config as detailed in the images below

using_csv_for credentials1

using_csv_for credentials2

3. Add the JSON Path Extractor that we will use to extract the token from the response as in our case the response is in the JSON format like the following:


{

"data": {

"id": "a964a723ecfb61ba5e54d8cd22420f20",

},

"status": {

"httpStatus": 200,

"success": true

}

}

using_csv_for credentials3

using_csv_for credentials4

The expression that we use in the JSON Path Extractor is $.data.id as this refers to the id field in the data object. You need to adjust this to match your JSON format from the response.

4. Create the call that will access the area in the web application for which the user needs to be logged in and add the HTTP Header Manager that will use the token as a X-CSRF-Token like in the image below

using_csv_for credentials5

using_csv_for credentials6

You are all done, now you can access any part of your web application that needs the user to be logged in using the same process that we used at step 4.

Enjoy.

 

Uncategorized

Reading Time: 2 minutes

In order to make sure that your application will not break under a heavy load, a web application owner has to perform some basic performance tests.

Here are 4 simple steps how to achieve this with LoadFocus load testing tool:

  1. Log into your account on the LoadFocus platform
  2. Click on the “New Load Test” menu
  3. Enter the details of your web application (the endpoint/URL that you want to access, the number of clients per second and the number of seconds that the test will run) – check image attached for an example
  4. Before starting the test log into your server and use the script that we provide for monitoring the CPU and memory as below (the script is developed for Linux servers):
    1. copy the script cpu_mem_stats.sh to the server where your application is installed: click here to download script.
    2. run the following command:
      
      chmod 777 cpu_mem_stats.sh
      
    3. run the following command:
      
      ./cpu_mem_stats.sh -p node -t 200 -f /home/ubuntu/log.txt -c true
      
    4. the meaning of the parameters is (please modify according to your needs):
    • -p – The process name to look for
    • -t – The time to monitor specified in seconds
    • -f – path to the file to write the output (if not specified the output will be logged into the console)
    • -c – if specified as true will output in CSV format
    1. Start your load test from LoadFocus.com
    2. The result of the response times will give you a graph like this:
    3. After the test ends get the result from the stats test on your server (in our example log.txt)
    4. For creating the graphs from the result files we recommend the following online solution: https://plot.ly/ . From that you will get a graph similar to:
    5. Now by using the graphs from LoadFocus.com and the results from the cpu_mem_stats.sh you can correlate how you server is behaving under load, which will give you an idea if the machine needs to be upgraded or is enough to support the load your clients will generate.

Uncategorized

Reading Time: 1 minute

The JMeterPlugins-Extras contains additional plugins for extended testing and complex testing. Also it does not require additional libraries to run.

The JmeterPlugins-ExtrasLibs contains additional plugins that do require additional libs to run.

How to install :

  1. Download from http://jmeter-plugins.org/downloads/file/JMeterPlugins-Extras-1.2.1.zip; in case the link does not work anymore it must be because the version has been updated so please visit http://jmeter-plugins.org/ and download the latest version for the Extras Set
  2. Download from http://jmeter-plugins.org/downloads/file/JMeterPlugins-ExtrasLibs-1.2.1.zip; download the latest version for the Extras with Libs Set from http://jmeter-plugins.org/
  3. Once downloaded, extract JMeterPlugins-Extras-1.2.1.zip into a temporary location
  4. Copy the folders contents from the archive in the JMeter plugin installation directory (the folder structure in the zip file matches the folder structure in the JMeter tool installation directory)
  5. Once the files are copied in the correct folders inside JMeter’s installation directory, restart JMeter and the new plugins will be present

LoadFocus Team

Enjoy!