Tuesday, August 14, 2012

Selenium IDE Tip - Continue if only element is present else not

Selenium IDE Tip - Continue if only element is present else not


In the following code, first check element is present or not.

If not present, then exist from the loop to the label - exit, else continue the commands - verify Text

This really helps when we want to run specific TC or not??


<tr>
<td>storeElementPresent</td>
<td>${category_header_obj}</td>
<td>present</td>
</tr>
<tr>
<td>gotoIf</td>
<td>storedVars['present']==false</td>
<td>exit</td>
</tr>
<tr>
<td>verifyText</td>
<td>${category_header_obj}</td>
<td>Categories</td>
</tr>

Monday, August 13, 2012

How to use if else condition in selenium ide

How to use if ...else condition in selenium ide ???


1. Download the below file & store in option > file list.
2. Open the selenium ide

one example is shown below

Example:
store     | 10                  | x
gotolabel | target1             |
getEval   | alert("Skip This"); |
label     | target1             |
store     | 14                  | y
gotoIf    | ${y} > ${x}         | target2
getEval   | alert("Skip This"); |
label     | target2             |
while     | storedVars['x'] <= storedVars['y'] |
getEval   | storedVars['x'] = ${x} + 1; |
endWhile  |                     |
getEval   | alert("Finished");  |
The following commands are available:
goto       gotoAndWait        gotoIf     gotoIfAndWait
gotolabel  gotolabelAndWait   while      whileAndWait
endWhile   endWhileAndWait
Download the file 

How to use - String functions ??



1. trim()


<tr>
<td>storeEval</td>
<td>"${deliverych1_price_val}".trim()</td>
<td>deliverych1_price_val</td>
</tr>

Selenium IDE Tips