help me to detect page with wait.until

78 views
Skip to first unread message

Yevgen Ko

unread,
Jun 16, 2014, 3:16:45 AM6/16/14
to seleniu...@googlegroups.com
I am a newbie and just learning Selenium.
On the orbitz.com after clicking "Search" button another page is loaded. To identify that page I use html body id:
WebDriverWait wait = new WebDriverWait(wd, 60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("resultsTwoColumn")));
But after page loaded my program never detects new page.
Appreciate for any help.

Vishnu

unread,
Jun 16, 2014, 5:12:22 AM6/16/14
to seleniu...@googlegroups.com
Please try the below query.

                WebDriver driver = new FirefoxDriver();
driver.get("http://orbitz.com");
                 //Maximize the window
driver.manage().window().maximize();
//wait for 10 sec
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Input on Where textbox
driver.findElement(By.name("hotel.keyword.key")).sendKeys("London, United Kingdom");
//clicking on Search button
driver.findElement(By.name("search")).click();
//wait for 20 sec
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Input on HotelName in the new page
driver.findElement(By.xpath("//*[@id='rail']/div[3]/div/div[2]/div/form/div/div/fieldset/label/input")).sendKeys("Charlotte");
System.out.println("End");

Oscar Rieken

unread,
Jun 16, 2014, 11:24:22 AM6/16/14
to seleniu...@googlegroups.com
unless you work for orbitz I would suggest you get their permission before writing automation on their site. 


--
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/eb2395a5-a4c3-4a81-abb9-74e2b0018688%40googlegroups.com.

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

Yevgen Ko

unread,
Jun 16, 2014, 3:12:07 PM6/16/14
to seleniu...@googlegroups.com
Thanks, Vishnu!
I guess
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

works the same way as
Thread.sleep(20000);

but is there any way to make
 wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("resultsTwoColumn")));

to work or is it not good idea?

Connor Gilbert

unread,
Jun 16, 2014, 5:06:59 PM6/16/14
to seleniu...@googlegroups.com
I was under the impression driver.goto always waited for the page to load before doing the next action.

Could someone verify this?

Vishnu

unread,
Jun 16, 2014, 9:12:17 PM6/16/14
to seleniu...@googlegroups.com
Hi Yevgen,

implicit wait and thread.sleep are not same.

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); --- Maximum wait is 20 sec if element found before 20 sec, it will proceed further. Most appreciate method and browsers maximum load will be 30 sec. You can keep 30 sec maxi for your project.

Thread.sleep(20000); --- It will wait for 20 sec even if the element is present before that or element is not present. fixed timings.

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("resultsTwoColumn"))); --- I have no idea about this.

Yevgen Ko

unread,
Jun 16, 2014, 11:11:04 PM6/16/14
to seleniu...@googlegroups.com


On Monday, June 16, 2014 6:12:17 PM UTC-7, Vishnu wrote:
Hi Yevgen,

implicit wait and thread.sleep are not same.

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); --- Maximum wait is 20 sec if element found before 20 sec, it will proceed further. Most appreciate method and browsers maximum load will be 30 sec. You can keep 30 sec maxi for your project.

Thread.sleep(20000); --- It will wait for 20 sec even if the element is present before that or element is not present. fixed timings.

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("resultsTwoColumn"))); --- I have no idea about this.

      
        WebDriver wd = new FirefoxDriver();
        wd
.get("http://www.orbitz.com");
        wd
.findElement(By.name("search")).click();

       
WebDriverWait wait = new WebDriverWait(wd, 60);

        wait
.until(ExpectedConditions.visibilityOfElementLocated(By.id("resultsTwoColumn"))); //check every 60 seconds till id=resultsTwoColumn is available.


Reply all
Reply to author
Forward
0 new messages