How to select an element from table if there is no ID

When we want to select a value from a table but the element doesn’t have id or other identification, we can use the other cells of the table to identify the value.

For example:

Table

<table id="business_marketData_items" summary="Current market values for major international indexes">
<tbody>
<tr>
<td><a href="http://www.bbc.co.uk/news/business/market_data/stockmarket/2/">Dow Jones</a></td>
<td>14828.78</td>
<td><span>+</span></td>
<td>116.23</td>
<td>0.72%</td>
</tr>
<tr>
<td><a href="http://www.bbc.co.uk/news/business/market_data/stockmarket/12122/"> Nasdaq</a></td>
<td>3312.14</td>
<td><span>+</span></td>
<td>32.88</td>
<td>0.85%</td>
</tr>
</tbody>
</table>

There is a table with stock market data and we want to get the value of the percentage of change (the last column). The percentage doesn’t have any identification, but we know the name of the stock market. For example we choose Dow Jones and the desired value is 0.72%.

How to get the value?

Getting started with JMeter II – record traffic with Jmeter

Here will be described how to simply record traffic with Jmeter. The HTTP Proxy Server allows Jmeter to watch and record the traffic and stores them directly into the test plan.

First download and install all necessary packages:

1. Java

http://www.oracle.com/technetwork/java/javase/downloads/index.html

- After install setup the environment variables

2. Jmeter

Download Jmeter from following website, select the latest zip file:

http://jmeter.apache.org/download_jmeter.cgi

Download Jmeter

Webdriver – XPath and CSS selector performance tip

There are cases when using XPath has some advantages over CSS selectors.
For example if there is a site where we can select an item only by text because the other type of locators are not clear(id’s and classes are generated and they are used in multiple places).

What can we do in this situation?
  1. Use a CSS locator to select multiple elements and then call the getText() function and compare the results with the selected string
    This is a working solution, but Webdriver calls are expensive and it can really slow down test runs in IE8 and IE9 browsers.
  2. Use the XPath’s contains function to select the element by its text value
    span[contains(text(),'Text to search for')]
Short background story:

To solve our initial problem using CSS we have been forced to use the getText() function to be able to compare the text and get the appropriate element.
When we came up with the 2. solution the overall run time of the tests have been reduced and the test runs became more stable in IE8 and IE9.

Getting started with JMeter

JMeter may be used to test performance, to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types.

First download and install all necessary packages:

1. Java

- http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Setup the environment variables

2. Jmeter

- Download Jmeter from following website, select the latest zip file:
http://jmeter.apache.org/download_jmeter.cgi
Jmeter download

How to integrate a JUnit4 – Webdriver test into JMeter

JMeter is an open source load testing tool, with many capabilities. One of the many interesting things which can be done is to integrate a webdriver test into a JMeter test suite.

Before start make sure that Java and JMeter properly installed, and the webdriver libraries are downloaded. You can download them from the following links:

The following step is to create a new project in Eclipse with a webdriver test. To keep it simple the test just hits the google.com page, and will check its title.

To create a project:
- Click File -> New- > Java Project

New Java Project

New Java Project

- Enter project name -> click Finish

New Java Project Name

New Java Project Name

Configuring Selenium RC using Eclipse

This tutorial describes Eclipse setup to use with Selenium. First download all the necessary packages:

  1. Download Java JDK from:
    http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Download Eclipse IDE for Java Developers :
    http://www.eclipse.org/downloads/
  3. Download and Install Selenium IDE firefox plugin(needs browser restart):
    http://seleniumhq.org/download/
  4. Download Selenium RC server and Selenium Client Drivers for Java:
    http://seleniumhq.org/download/

When all these packages are downloaded install first Java JDK. After install setup the Environment variables (java home, path).
After that extract Eclipse to folder C:\ECLIPSE

Extract Eclipse

How to get data from input field or from textarea?

Get data from input field or from textarea

In certain situations we need to get data from input field or from textarea.

The selenium getText() function is not good to get the data from input filed (<input>) or from textarea (<textarea>).

driver.findElement(By.xpath(TEXTAREA.XPATH)).getText()returns an empty string.

The solution is to use getAttribute(“value”).

driver.findElement(By.xpath(TEXTAREA.XPATH)).getAttribute("value");

Comparison of web-based bug tracking tools

IT projects need a bug tracking (or issue tracking) system. Having a bug tracking system is extremely valuable in software development. They are used extensively by companies developing software products and applications.

There are lot of web-based bug tracking / project tracking tools. We tested the following tracking tools:

This test was a simple usability test and during testing the focus was on the following:

  • creating a new bug -  simple or not
  • new file upload – simple or not
  • uploading screenshot ability
  • tools for Windows, Mac, mobile devices
  • other (searching for tickets, comments…. )

Test complete – first impressions

As a QA engineer today, it is hard to choose the right tools to help us get our job done and to remain competitive. There is a constant need to try out and learn how to use these new tools.

Today we will look into TestComplete.

On their site, there is a one-month trial which can be downloaded and installed. The application is well documented and there are a lot of video tutorials which can speed up the learning process.

Here are some instructions for those who want to quickly try out this tool:

1. To create a test suite open TestComplete and click on “Create a New Project”.

Create a New Project

Enter project name and click finish.

Enter Project Name

Capturing screenshots of failed tests in Selenium Webdriver + JUnit4

Beside the exception / failure information, it is almost always helpful for the developers to provide them with additional screenshot of the failed tests.
From JUnit 4.7 the @Rule annotation is introduced which can be used to extend the capabilities of JUnit. With it we can invoke a custom piece of code when a test fails or succeeds.
In this example we will capture a screenshot of a failed test.
Before showing how it is done, we should have a test class at hand. For the following example just download the selenium driver from the page http://seleniumhq.org/download/ and add the jar files to classpath.

package test;

import static org.junit.Assert.assertTrue;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;

import com.thoughtworks.selenium.Selenium;

//This is an example for the usage of ScreenshotTestRule
public class TestWithScreenshotExample {
    //
    static WebDriver driver;
    static Selenium selenium;
    // an annotation is used for defining a new rule for Junit
    @Rule
    public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule();

    @BeforeClass
    public static void beforeClass() {
        driver = new FirefoxDriver();
        selenium = new WebDriverBackedSelenium(driver, "http://www.google.com");
    }

    @AfterClass
    public static void afterClass() {
       driver.quit();
    }

    @Test
    public void testThatSucceeds() {
        selenium.open("/");
        // some text code here
        assertTrue(selenium.isTextPresent("This test will pass"));
    }

    @Test
    public void testThatFails() {
        selenium.open("/");
        //some text code here
        assertTrue(selenium.isTextPresent("This test will fail"));
    }

    // the static driver object will be needed for capturing screenshots
	public static WebDriver getDriver() {
		return driver;
	}

The trick above is to define a new JUnit rule with @Rule annotation.
The class which is used to define the new rule needs to implement the MethodRule interface and to override the apply() function.