Click here to edit title

Click here to edit subtitle


Testing with Selenium using commands While and XPath

Posted by JJ on May 19, 2014 at 4:50 PM


I decided to write this post to help with 3 functions of Selenium IDE. And I translate for to english, for my friends Indians, with we study selenium. So, sorry about my english, again. And too, sorry my, brasilian friends what know english best me.

1- Variable

2- While

3- XPath

So, what doing my scrit basicaly?


He create an environment for repeatition, and I can insert one any test.

In the example, I insert a test, what was to click in a button "Convidar" of a Facebook fanpage. For this test, I insert a quantity of repeat of 50 times.

Inserting a condition wherein While is until 50, I start to test agin.


Well, my test will to click in the button "Convidar" for invite my friends to like fanpage of 4All Tests. But you joke with the script wherever


Before ending the condition,  after the test Increment the variable, so, after at 13th test he incrementing the variabel, going for the 14th test(this is an example)

The part interesting, is to use the XPath, and my test get consistent in case where Id of button changes.


I post an article translate to portuguese about XPath

So, our test automation like this:


*Look this,  it is important put a bar over there in target, because it is copied whith only a single bar. '//'

So look how our script works

On the step 1, he open the fanpage

Step 1

On the step 2, I declare my variable "QTD" and i change the his value for "1"

Step 2

In step 3, the condition of my command "While" checks if the my variable "QTD" is less than or equal to 50. If so, to do the test, if it is not less than or equal to 50, or 50 is equals or higher (51, ​​52 ...) for this condition and it goes straight to "EndWhile" command.

Step 3

In step 4 I will do all that is in my test, yes(in example), click the invite button.

Step 4

In step 5, after my test I add to the variable "QTD" the value "1" plus the value that is in "QTD".

Step 5

The script for download here" target="_blank" rel="nofollow">in git.

So, brothers, sorry my english, and I not used google translate, kkkkkk.

And, rememer:

Testing software is not breaking it. It look simple and develops it.

Categories: Automatizacao, Artigos, Estudar

Post a Comment


Oops, you forgot something.


The words you entered did not match the given text. Please try again.

Already a member? Sign In