Selenium wait

133 views
Skip to first unread message

Dimuth Lasantha

unread,
Mar 3, 2015, 5:03:11 AM3/3/15
to seleniu...@googlegroups.com
HI,

I want to wait the browser and i used following code segment 

driver.manage().timeouts().pageLoadTimeout(2, TimeUnit.MINUTES);

but browser does not wait 2 minutes 


Cheers

PeterJeffreyGale

unread,
Mar 3, 2015, 5:10:28 AM3/3/15
to seleniu...@googlegroups.com
That's because it's a timeout and not a wait.

Just use a Thread.Sleep call if you want a fixed wait.

CH!NN@ K

unread,
Mar 3, 2015, 5:41:56 AM3/3/15
to seleniu...@googlegroups.com
Hi Dimuth Lasantha, check below link for Synchronization commands :

http://techlearn.in/content/extract-links-particular-section-using-selenium


 Synchronization :-
 

  • Thread.sleep(9000);
     

  • selenium.waitForPageToLoad("9000");
     

  • WebDriverWaitwait=newWebDriverWait(driver,9);
    wait.until(ExpectedConditions.elementToBeClickable(By.id("Element-id")));

     

  • driver.manage().timeouts().implicitlyWait(9,TimeUnit.SECONDS);


---
Thanks & Regards,
Purushotham Karimbedu,
Drupal Developer and QA Engineer,
Website for Selenium : http://techlearn.in


On Tue, Mar 3, 2015 at 3:40 PM, PeterJeffreyGale <peterjef...@hotmail.co.uk> wrote:
That's because it's a timeout and not a wait.

Just use a Thread.Sleep call if you want a fixed wait.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/01ee30d3-8c9b-44a6-a41d-a39382b3f656%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David Lai

unread,
Mar 3, 2015, 1:23:30 PM3/3/15
to seleniu...@googlegroups.com
First Off,

Page load just means HTML document.ready() event has fired.  It does not indicate if the corresponding CSS or JavaScript has fully loaded or not.


Second,

I think hard coded waits are dirty.

What I like to do is create a simple utility class that basically waits for all the elements on a page object to instantiate.  It's a pretty simple utility to write, and makes waiting for pages very easy.

It basically consists of 2 parts,

1 -  a poll loop that waits for the PageFactory to properly instantiate the page object,
2 -  a secondary queue that waits for all mapped elements of that page object to be available.  You can do something fancy like make this part wrapped in a decorator so you can pick and choose which mapped element gets picked up for waiting.

Dimuth Lasantha

unread,
Mar 3, 2015, 10:53:55 PM3/3/15
to seleniu...@googlegroups.com
Hi,

My code segment is 

if(flash.equals("Sorry, failed to invite the user.")){

do{

i++;

driver.findElement(By.xpath(".//*[@id='designation_profile_attributes_email']")).clear();

driver.findElement(By.xpath(".//*[@id='designation_profile_attributes_email']")).sendKeys("hiveagetest+"+i+"@gmail.com");

driver.findElement(By.xpath(".//*[@id='workspace']/div/div/div[1]/header/div[1]/button")).click();

flash = driver.findElement(By.xpath(".//*[@id='flash']")).getText().toString();

//wait.until(ExpectedConditions.invisibilityOfElementWithText(By.xpath(".//*[@id='flash']"), "Saving..."));

System.out.println(flash);

}while(flash.equals("User has been invited."));

//flash = driver.findElement(By.xpath(".//*[@id='flash']")).getText().toString();

}

i want to wait until disappear "Saving..." flash message and appear "Sorry, failed to invite the user." or "User has been invited.". 

i could not find any solution from selenium.

David Lai

unread,
Mar 4, 2015, 11:54:16 AM3/4/15
to seleniu...@googlegroups.com
I think you should be able to use a webdriverwait.  

A lot of people don't know this, but you can also pass in a lambda expression into WebDriverWait to wait for the opposite, such as an element disappearing or some other wait condition.

Krishna

unread,
Mar 6, 2015, 12:24:58 AM3/6/15
to seleniu...@googlegroups.com
Hi Guys,

Sorry that my reply is not related to this post.

I have  completed my first script in Selenium and it is running fine in Firefox. But when it comes to ie and Chrome it starts failing. Can u please help me with this?

Regards,
Vamsi

PeterJeffreyGale

unread,
Mar 6, 2015, 5:36:30 AM3/6/15
to seleniu...@googlegroups.com
Start a new thread an give some more details of what the problem is.
Reply all
Reply to author
Forward
0 new messages