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:
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-222222-3");
pageTracker._trackPageview();
} catch(err) {}</script>
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
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5