Archive

Archive for May, 2016

How to set a list of jmeter properties with a list of jmeter variables

Hey guys, today I will post about a quick code to set properties in runtime from jmeter variables.
Where you could use this ?
If you have a list after extract with json path extractor and you want to set a property to use in another thread group, this could be useful.
For example, I will get the serials of a list extracted with json path extractor.
– Create a beanshell script with:
//Get the count of the serials
String countSerials = vars.get("serials_matchNr");

// create a for to create a property for each serial variable
for(int i=1;i<Integer.parseInt(countSerials);i++){

   //set each property + index with the variable of each serial in the list
   ${__setProperty("serials_"+i,String.valueOf(vars.get("serials_"+i)))};

}
Thank you guys ! See you next week 🙂
Advertisements

Comparing @FindBy and Map repository approaches

What is this @FindBy ?

It’s an annotation on Selenium that organize the elements and using the PageFactory, these WebElements are usually initialised when a Page Object is created. It’s a best practice of Page Object Models, but more than this is a way to let your group of elements well-structured and just call when you need it.
The @FindBy annotation is used to locate one or more WebElements using a single criterion. For example:

@FindBy(id = "id_element")
private WebElement element;

 

To create the instance for these elements, you can use:

PageFactory.initElements(driver, this);

 

For the cases you want to search for all the given criteria, you can use @FindBys and for the ones you want to search for at least one of the given criteria, @FindAll

So, for example:

Using @FindAll:

@FindAll({
    @FindBy(name = "username"),
    @FindBy(name = "password")
})
private List<WebElement> loginfields;

The loginfiends list should contain the element with name = username and the element that contains name = password, 2 elements. If you use @FindBys it wouldn’t bring anything, since there is no element with two names (both of the criteria).

So, this structure makes the code much easier to read. You should place the @FindBy in the beginning of your page object class.

What is the Object repository ?

It could be a properties/text file where you place all the locators for the elements and you use selenium to call each one. The property file contains a collection of key-value pairs, with the key being a logical name identifying the object and the value containing unique objects properties used to identify the object on a screen. You can use this concept of Object Repository for any language, not only Java and not only with Selenium.

It contains the key of the element and the value to find it. The corresponding value consists of two parts: the attribute type used for uniquely identifying the object on screen and the corresponding attribute value.

Screen Shot 2016-05-21 at 20.05.19

After this, you need to create a class to get the elements . For example:

Screen Shot 2016-05-21 at 20.34.38

As you can see, objects can be identified using a number of different properties, including object IDs, CSS selectors and XPath expressions.

Now you can use these in your scripts to execute any scenario. You just need to call the Map repository and get the locator key.

Screen Shot 2016-05-21 at 20.42.57

So, in the end you just need to update this properties file with the new locators.

The aim of both of the methods is to reduce the maintenance time when you have new locators. If you are using Selenium, I suggest you to use @FindBy since it’s a good practice and the framework provides this option, but you don’t have this for all the test frameworks in the market, for those you can have a map repository.

Cheers guys, see you next weekend 🙂

 

Resources:

http://www.ontestautomation.com/findby-strategies-for-selenium-explained/

http://www.ontestautomation.com/building-and-using-an-object-repository-in-selenium-webdriver/

Test Automation Obstacles On Demand

Hey guys, today I will post a webinar that I’ve watched last week. It’s about the challenges of test automation:

  • Collaboration
    • Daniel explains that is easy to ask developers to write test automation and for this reason, it’s better to choose the same language of the developers
    • Assign an owner for the digital test coverage but keep the conversation open to all teams
  • Tools
  • Reports
  • Flows
  • Time
  • False negatives
  • Stability
    • Object identification is the key for robust automation
    • Assure proper Error handling
  • Security
    • Networks
    • Orientation
    • Location
    • Notifications
    • Events
    • Device events

Here is the video, but you can have a look on the slides on the link below:

Sourcehttp://info.perfectomobile.com/Overcoming-Test-Automation-Obstacles-On-Demand-Replay.html?mkt_tok=eyJpIjoiTkRKaVlUY3lZbVk0TTJaaiIsInQiOiJZV2w2VWtxMkk0a214d29ETmNvaFpodENQeHllTUcrMkYycU05bEV1WmhIYzQyUTBhS3NoRjA5TFFuTTN6S3NcL1ZPaDQ1YWtBNmRSZDRcLyt4eVdyVk5ES1FBS0MrWVwvSU5WUGZVZ0VwVGI1ST0ifQ%3D%3D

Continuous Deployment – 14th SDET Meetup

So, I will post a video that I’ve recorded (the sound is not great), about continuous deployment which was one of the talks in the 14th meetup that I went last week.

It had more 2 interesting talks, but my phone was full and I couldn’t record more 😦

Thank you guys !

%d bloggers like this: