better method to make page navigation process

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

better method to make page navigation process

Muaaz
Guys ,

I have been using RC for a while now , there is always automation test failures when system tries to open a new page , basically timeouts when we navigating to page , currently i am using following methods , but i need a better way to minimize this kind of silly problem , due to this most of my test suites get failed even i increased the pause time limits each and every time ,


if(!selenium.isElementpresent(element))  , or selenium.isTextpresent("relevant text")
{
pause(30000);
}
 

while(!selenium.isElementpresent(element))
{
pause(30000);
}


 when we run the test suite unmanned , most of the test cases triggers on IF and While statements ,
but when we run again it passes without any failure , this is getting buzzing me always .... without a solution ,


Please provide me a better solution for this ,

Thank you ,
Reply | Threaded
Open this post in threaded view
|

Re: better method to make page navigation process

softwaretestingforum
Administrator
I suppose you are referring to open method to open a new page and then it times out, is it?
Did you try using setTimeOut after open method?
If this also does not wait for longer enough then you can try catch block -

try{
selenium.open("URL here")
} catch(Exception e) {
e.printStackTrace();
Thread.sleep(10000); // increase the time if needed.
}

Looks an ugly solution but may trick.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: better method to make page navigation process

Muaaz
cant we set like test script should wait until relevant page appear ,
because due to system performance , time may differ ,


in your previous code example , it will wait until some limited time span what we have set. just imagine we dont know the time limitation , then how do we that , ???

because i need to make my script same as manual testing (replacement for manual testers )....  :-)


and are we need to setTimeout after the open command is it ...
Reply | Threaded
Open this post in threaded view
|

Re: better method to make page navigation process

softwaretestingforum
Administrator
I agree conditional wait is the way to go. You could try this -

try {
selenium.open("URL here");
} catch (Exception e) {
 for (int i=0; i<60;i++) {
   if(! selenium.isElementPresent("elementlocator") {
     Thread.Sleep(1000);
    } else {
      break;
    }
  }
}

This script would wait for at most one minute (as limit is set to 60 in for loop) and if your page is loaded before that (that is when "if" condition is specified) then control would come out of loop and continue execution of rest of the tests.

About setTimeOut method, by default open method wait for only 30 sec for page to load and if you want to increase the wait period then you should use setTimeOut after open method. I had never got setTimeOut working and can not say if it works now as I don't use Selenium RC any more. Hence I used to use solution I described above.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: better method to make page navigation process

Muaaz
Great Stuff Tarun , A very big Thank you ,