Friday 14 October 2011

Replace value in XPath with Variable

Below is the sample piece of code for submitting the variable into XPath.
Selenium IDE
<tr>
    <td>store</td>
    <td>2</td>
    <td>a</td>
</tr>

Verify the A value
<tr>
    <td>echo</td>
    <td>${a}</td>
    <td></td>
</tr>

//Replace the hardcoded value with a
<tr>
    <td>click</td>
    <td>//*[@id='ctl00_Main_DropDown']/div/ul/li[${a}]</td>
    <td></td>
</tr>

In Selenium RC
String a = "2";
System.out.println(a);
selenium.click("//*[@id='ctl00_Main_DropDown']/div/ul/li[" + a + "]");

Monday 10 October 2011

dragAndDropToObject


Selenium IDE doesn't support Drag and Drop by recording but it can support if we add manually. Below is the sample piece code for dragAndDropToObject.

Selenium IDE
<tr>
    <td>dragAndDropToObject</td>
    <td>//*[@id='ctl00_chMain_Period']/span</td>
//Locator value of element to be dragged
    <td>//*[@id='ctl00_chMain_Period']/ul/li[5]/span</td>
//Locator value of destination object
</tr>
Selenium RC
selenium.dragAndDropToObject("//*[@id='ctl00_chMain_Period']/span", "//*[@id='ctl00_chMain_Period']/ul/li[5]/span"); 




Friday 7 October 2011

StoreAttribute

It is very important in automation to store the specific attribute to verify in next iteration.

Below script will explain how to use the  StoreAttribute command

<tr>
    <td>storeAttribute</td>
    <td>//*[@id='lst-ib']@name</td>
    <td>Attribute</td>
</tr>
<tr>
    <td>echo</td>
    <td>${Attribute}</td>
    <td></td>
</tr>

Let me know if you have further doubts.