How do you get selenium to recognize that a page loaded?

后端 未结 9 1495
误落风尘
误落风尘 2020-12-16 19:40

In certain unknown situations selenium does not detect that a page has loaded when using the open method. I am using the Java API. For example (This code will not produce th

相关标签:
9条回答
  • 2020-12-16 19:58

    Enabling the 'multiWindow' feature solved the issue, though I am not clear why.

    SeleniumServer(int port, boolean slowResources, boolean multiWindow)

    SeleniumServer server = new SeleniumServer(4444, false, true);
    

    Any clarification would be helpful.

    0 讨论(0)
  • 2020-12-16 20:04

    Using 'openAndWait' in place of 'open' will do the trick.

    From the website:

    Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.

    0 讨论(0)
  • 2020-12-16 20:06

    I've run into similar issues when using Selenium to test an application with iFrames. Basically, it seemed that once the primary page (the page containing the iframes) was loaded, Selenium was unable to determine when the iframe content had finished loading.

    From looking at the source for the link you're trying to load, it looks like there's some Javascript that's creating additional page elements once the page has loaded. I can't be sure, but it's possible that this is what's causing the problem since it seems similar to the situation that I've encountered above.

    Do you get the same sort of errors loading a static page? (ie, something with straight html)

    If you're unable to get a better answer, try the selenium forums, they're usually quite active and the Selenium devs do respond to good questions.

    http://clearspace.openqa.org/community/selenium_remote_control

    Also, if you haven't already tried it, add a call to browser.WaitForPageToLoad("15000") after the call to open. I've found that doing this after every page transition makes my tests a little more solid, even though it shouldn't technically be required. (When Selenium detects that the page actually has loaded, it continues, so the actual timeout variable isn't really a concern..

    0 讨论(0)
提交回复
热议问题