Welcome to Selenium Recipes

Welcome to the website. I built this website to work as a collection for all things Selenium, and to start gathering together some of the best content on the web for Selenium. I also built this site so that I and others can showcase how to use Selenium in both conventional and unconventional ways.

is element present

Here is how to do it in webdriver:

if(!driver.findElements(By.xpath("//*[@id='submit']")).isEmpty()){
//THEN CLICK ON THE SUBMIT BUTTON
}else{
//DO SOMETHING ELSE AS SUBMIT BUTTON IS NOT THERE
}

Tags: 

How to find and remove a value from an array

If you are working with an array and you need to remove an item from the array, here is how to do it:

 

The second storeEval command finds the index value of the item in the array. This is helpful if you dont know what the index value is since the items may have been loaded into the array in a random order. The last storeEval command removes the item from the array by the index value from the second storeEval command.

Tags: 

Using Drupal AND Selenium for data driven testing

This may sound a bit strange to many of you ... but, we have engineered a way to create a framework for managing scheduled selenium launches, and providing data into each launch (data driven) using a Content Management System (Drupal). For  our needs, we needed the ability to have a separation between data and the scripts themselves. I should menton that we are a performance engineering team;although, this method has also been used for functional testing. We were looking for browser-based (not synthetic) single instance performance testing metrics.

Tags: 

Finding a available port number in Windows

See the following page for some clever code for finding an available port number in Windows to start an instance of the selenium server. This is handy when you are trying to start multiple instances of selenium and need port numbers that are not in use.

http://www.seleniumrecipes.com/content/searchport-batchfile

Tags: 

DRUPAL: How to use Rules to create child nodes from parent and populate child fields from parent fields

I use the Drupal content management system as a companion to the Selenium automation tools so that I get robust reporting and data manipulation. I also use it to perform parameterized data driven test scripts. I decided to use Drupal and Selenium for an update/deployment mechanism for my testing framework ... so that if there were any updates to framework based files (including user-extensions) in our local machines c:\selenium directory, an Update node (form entry) could be created on the frameworks website.

Tags: 

Pages