Verifyelementpresent

How to use Verifyelementpresent in Selenium 

You can use selenium.IsElementPresent(“element”) to see if a particular element is present on the web page. This is a very powerful function in selenium as you can use it with a if condition.
In this example I am first checking if there is an element //td[@class='Selenium'] on the web page. If yes then I click the element //td[@class='Selenium'] and continue checking the other conditions.

More…

By Pavandeep Puddupakkam on July 21, 2010 | Selenium RC | 1 comment
Tags: , ,

Using Xpath in Selenium and Selenim RC 

The HTML Example Document

<div>
<ol>
<li>
<a title="Self Catering Apartments" href="http://www.ooo.coo">Self Catering Apartments</a>
</li>
<li>
<a title="Vacation Accommodation" href="http://www.ooo.coo">Vacation Accommodation</a>
</li>
<li>
<a title="Hotel" href="http://www.ooo.coo">Hotel</a>
</li>
<li>
<a title="Real Estate" href="http://www.ooo.coo">Real Estate</a>
</li>
</ol>
</div>

Uisng xpath to verify all the a tag elements
xpath = //div/ol/*/a[@href]
This will return all the a tag elements
In selenium you can use this command to verify if the elements have the href

More…

By Pavandeep Puddupakkam on March 3, 2010 | Selenium IDE, Selenium RC, Software Testing | A comment?
Tags: , ,

How to use selenium to check for google analytics on a web page 

I have used xpath to verify if a particular string is available on the web page. Using the same concept I am now able to verify if google analytics code is available on the web page.
Here is the example:
Say my google analytics code is something like this:
[JavaScript]script type=“text/javascript”
try {
var pageTracker = _gat._getTracker(“UA-222222-3″);
pageTracker._trackPageview();
} catch(err) {}script
[/JavaScript]
The xpath for that is //script[@type="text/javascript"][contains(text(), 'UA-222222-3')]
Then you use verifyElementPresent in selenium. I hope this will be useful for you all.

<tr>
<td>verifyElementPresent</td>
<td>//script[@type='text/javascript'][contains(text(), 'UA-222222-3')]</td>
<td></td>
</tr>

Submitted by Puddupakkam Pavandeep

By Pavandeep Puddupakkam on February 19, 2010 | Automation Tips, Selenium RC, Software Testing, XPath | A comment?
Tags: , ,