Tuesday, August 5, 2008

SeleniumIDE- Useful Points part-I

1- Xpaths:-
In one of my project when I was recording my script for create a post, I found that IDE is unable to record the text box activity. Actually that text box was Javascript content editor 'Tinymce' . Later I recognized that IDE is unable to find this editor as there was no label used for this. So I used X paths option available on right click to locate the element ID.
This was like id('tinymce')/p. Here title was not used so we need to pass it's ID manually. It is done using Xpaths .

2- Regular expression:-
Now in case if alert or pop up window appears so how you handle your script. I faced this situation and cane up with this solution.
Why our script fail. The reason is because the alert has a dynamic section and to handle that we need to put a regular expression marker with a regular expression. Your command should look something like verifyAlert ok.
you can also use assetX(asserttext, assetalert.....) for regular expression. I used this for select box functionality (Drop Down).

3-waitFor:-
I created a script and was trying to run this. But failed? why? Its times out!!!!! element not found!!!!! window not appear!!!!!!!....ect.
Actually what was happening , when my script start executing the page element was not loaded.
In AJAX base programing you never know, how long it will take to load the page element. This was the reason my script was failing again and again. Finally I came up with the solution using waitFor command. You can use this command to wait your script execution until the page element not loaded. (This is little similar to wait() command used in win runner )
Here are some expansion for this command : waitForX(waitForElement, waitForText, waitForAlert...........)

2 comments :

  1. Hello Vishal,

    Can you give me some information about Conversion Testing? You can e-mail me @ chandanamuddu@gmail.com.

    Thanks in advance.

    ReplyDelete
  2. Hey! Just stumbled upon your blog while struggling with setting up a test case with Selenium. Your point #3 - waitFor was exactly what I was looking for. Thanks a lot! And keep up the blogging.

    ReplyDelete