Re: Page not loading in Selenium webdriver browser - tried Wait and isDisplayed

6,438 views
Skip to first unread message

sai kiran nukala

unread,
Sep 6, 2012, 8:19:07 AM9/6/12
to seleniu...@googlegroups.com
Hi Sami,

I suggest you to put complete details about your problem in your own post rather than redirecting us to another link. Please put the entire details over here.

Coming to your problem - the issue might be in the below line of code, the locator may not be correct. Try to check whether the locator you have used is correct or not. AFAIK there is no limitation in number of pages that web driver can navigate. WebDriver is not able to find the element after 60 seconds therefore it is throwing TimeoutException.

  new WebDriverWait(driver, 60)
       .until(ExpectedConditions.presenceOfElementLocated (By.name("name")));

Thanks,
Sai

On Thursday, 6 September 2012 04:05:24 UTC+5:30, sami wrote:
Hi,
 
Please point me in the right direction. I am a beginner and I have tried many solutions to get past this issue
 
 
Appreciate your help. Why is the browser not loading the new page?  What should I try next?

sami

unread,
Sep 6, 2012, 1:21:30 PM9/6/12
to seleniu...@googlegroups.com

On Wednesday, September 5, 2012 3:35:24 PM UTC-7, sami wrote:
Hi,
 
Please point me in the right direction. I am a beginner and I have tried many solutions to get past this issue
 
 
Appreciate your help. Why is the browser not loading the new page?  What should I try next?
 

Hi I am just learning Webdriver. The flow that I am automating has 5 screens. 2 of the screens, I was able to navigate using webdriver. After details are input in the 2nd screen and ENTER is clicked, the 3rd screen is not getting loaded in the Webdriver browser.

When I try this manually this works fine. I have tried out various logic for waiting for the page to laod and searching for invisible elements.

is this some limitation of the webdriver browser?

   WebDriver driver = new FirefoxDriver();


   driver.get("url");         
  // Find the text input element by its name         
  WebElement element = driver.findElement(By.className("clicButton"));
   // Enter something to search for 
  element.click();
  System.out.println("completed start");
  WebElement element1 = driver.findElement(By.name("contactphone"));
  element1.sendKeys("number");          
  // Now submit the form. WebDriver will find the form for us from the element   
  //element1 = driver.findElement(By.id("the id"));
  //element1.click();
  element1.sendKeys(org.openqa.selenium.Keys.ENTER); 
  System.out.println("clicked continue");
  //WebDriverWait wait = new WebDriverWait(driver,10);
  //WebElement element2 = wait.until(driver.findElement(By.name("name")));

  //wait.until(driver.findElement(By.name("name")).isDisplayed());

  new WebDriverWait(driver, 60)
       .until(ExpectedConditions.presenceOfElementLocated (By.name("name")));

Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 60 seconds waiting for presence of element located by: By.name: name Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_20' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:255) at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:270) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:222) at LoadUsers.main(LoadUsers.java:49) Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: Command duration or timeout: 0 milliseconds

sami

unread,
Sep 6, 2012, 1:26:35 PM9/6/12
to seleniu...@googlegroups.com
Hi Sai,
 
Thanks for your reply. I have posted the entire details over here.
 
I have not mentioned the locator name exactly because of confidentiality.
 
I see that the webdriver browser is not going to the next page. Why is that happening. I have verified by clicking both submit button and using ENTER. Manually in firefox the 3rd page is loading but in the webdriver browser it is stuck on the second page.  In the bottom left pane I see the message "Transferring data from ip(numbers)" after this the page is stuck...

Mike Riley

unread,
Sep 6, 2012, 2:45:52 PM9/6/12
to seleniu...@googlegroups.com
You probably should set Implicit Wait time right away, because you are not waiting for any elements to be present here, so when you try to interact with them you get the exception.

You also have commented out a lot of lines here, so the way the code reads now you are sending an <Enter> to the input field that you just type "number" into.

Mike

Justin Gourley

unread,
Oct 3, 2012, 5:27:24 PM10/3/12
to seleniu...@googlegroups.com
Use (or place) something on each page, and then wait for that item to appear. Here are a couple functions I use:

public void waitForElementToBePresent(String locator, String locatorType, int timeoutInMilliseconds) {
        long startTime = System.currentTimeMillis();
        while (startTime + timeoutInMilliseconds > System.currentTimeMillis()) {
            try {
                if (isElementPresent(locator, locatorType)) return;
                Thread.sleep(1000);
            } catch (Exception e) {

            }
        }
        throw new RuntimeException("Waiting for element to be present timed out.");
    }

public Boolean isElementPresent(String locator, String locatorType) {
        if (getWebElements(locator, locatorType).isEmpty()) {
            return false;
        } else {
            return true;
        }
    }



On Tue, Oct 2, 2012 at 5:07 PM, ajohn <anu.j...@gmail.com> wrote:
Hi,

I am facing a similar situation. I have about 30 pages and I want to click the next element again and again until I reach the 30th page. But after the second click the page stops and the driver quits. But if I am using debugger I am able to click through the next element and navigate till the 30th page which is the last page. I am not able to figure out where the problem lies. My best guess is the webdriver is not waiting.I am using SafariDriver. I have tried using
implicit wait as follows

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);


Also is there some way I can assure that the new page has been loaded fully after I click next (next is a web element)

Any suggestion/tips is greatly appreciated.

Thanks 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/tal_Bk0TctIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike Riley

unread,
Oct 10, 2012, 2:50:04 PM10/10/12
to seleniu...@googlegroups.com
You are probably not giving it time to act on the click and end up clicking 30 times in rapid succession and exiting.  The debugger is slowing down the time between clicks enough for it to work, apparently.

Mike


On Tuesday, October 2, 2012 5:07:17 PM UTC-7, ajohn wrote:
Hi,

I am facing a similar situation. I have about 30 pages and I want to click the next element again and again until I reach the 30th page. But after the second click the page stops and the driver quits. But if I am using debugger I am able to click through the next element and navigate till the 30th page which is the last page. I am not able to figure out where the problem lies. My best guess is the webdriver is not waiting.I am using SafariDriver. I have tried using
implicit wait as follows

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);


Also is there some way I can assure that the new page has been loaded fully after I click next (next is a web element)

Any suggestion/tips is greatly appreciated.

Thanks 

On Thursday, September 6, 2012 11:45:52 AM UTC-7, Mike Riley wrote:
Reply all
Reply to author
Forward
0 new messages