When does driver.get() complete? - selenium

When using the InternetExplorerDriver (IE9 Win7) the driver.get() method blocks for some sites I'm testing. The site seems to be completely loaded, as the page is no longer refreshing, but the code just gets stuck at the driver.get() call. (this doesn't happen with the same site for the FirefoxDriver).
Anyone know any reason why this would happen or how best to troubleshoot it?
In particular the WebDriver api states
"the method will block until the load is complete".
How is "load is complete" defined?

Related

Selenium- "Waiting for xxxx"- Chrome

Website I am testing needs to load libraries from xxxx server.
Sometimes it takes to long and website display information Waiting for xxxx (I am using Chrome WebDriver).
Is it possible to treat it as an error and catch it using Selenium?
Sometimes when it takes to long and you see website display information Waiting for xxxx it is not actually an error. It means the the JavaScripts and the AJAX Calls associated with the Website are getting executed while the Page Loads. Once the JS & AJAX Calls gets executed completely, the Page Loading completes.
Now as per your question Is it possible to treat it as an error and catch it? the Answer is Yes.
This can be achieved by using the pageLoadTimeout method which Sets the amount of time to wait for a page load to complete before throwing an error.
Defined as pageLoadTimeout(long time, java.util.concurrent.TimeUnit unit), an example will be as follows :
driver.manage().timeouts().pageLoadTimeout(2, TimeUnit.SECONDS);
The error thrown is as follows :
Exception in thread "main" org.openqa.selenium.TimeoutException: Timeout loading page after 2000ms
You can find a detailed implementation of pageLoadTimeout in pageLoadTimeout in Selenium not working discussion.

a wait that stops the test till nothing is happening in the web page anymore

I am using Java and Selenium to write a test. Many times in my test i have to wait till the page or some part of it loads something. I want to wait till the load is finished. I found these two:
1) pageLoadTimeout
2) setScriptTimeout
But I don't know the exact difference between them or even if they are what I need.
The document says:
setScriptTimeout: Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.
and
pageLoadTimeout: Sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.
but I don't really get it.
what I need is a wait that stops the test till nothing is happening in the web page anymore.
Define "nothing is happening in the web page." Now define it in such a way that will satisfy every web page ever created, or that ever will be created. Did your definition include that no more network traffic is coming over the wire? Did your definition include that the onload event has fired? How about document.readyState returning a value meaning "complete?" Did you take JavaScript execution into account? How about JavaScript scheduled using window.setTimeout()? WebSockets? Service Workers? What about <frame> or <iframe> elements?
Now you know why WebDriver doesn't have a "wait for page complete" type of wait. The items mentioned above don't even begin to scratch the surface of the list of things a user could legitimately use in a definition of "nothing is happening on the page anymore." The correct approach would be to wait for the element you want to interact with on the next page to be available in the DOM. The WebDriverWait class is ideally suited for exactly this.

Handling self-refreshing pages (ajax) from selenium

I am new to selenium.
I have same problem with for which you have already answered,
I have attached my code here and explained where I am getting ajax problem.
I just started building my framework, it is just a groundwork I am doing and and stuck.
I try to use your code, getting errors.
with session() method I am getting error (expecting object).
TIMEOUT
what am I need to do to run your methods.
with Selenium2 have we got any new functionalities that are dealing with Ajax?

IE halts loading HTML page abruptly

Understanding that my problem could have a very vast scope of possibilities, I'll accept the answer that points me to something that I might have missed.
My software's client is facing this issue of page stopping loading in the middle and that too happens randomly. As usual, this does not happen in out network even with guys doing VPN from remotest parts of the world. The page is only 14 KB.
Its a web-based software that serves HTML via Apache over HTTPS. Client is using IE8 browsers.
We did network trace and found that not only number of bytes differ from our end to the trace at client's end, even encrypted packet sequence also differ (after a while in the stream). But that happens for successful request too!
Has someone experienced similar issue? What could corrupt the stream?
PS: I'm not too optimistic on getting answer here and going to post it to serverfault anyway. If someone thinks its off-topic, please feel free to close it.
It may be the operation aborted scenario which throws an error in IE7, but stops processing silently in IE8.
The HTML file is being parsed, and encounters a script block. The script block contains inline script which creates a new element and attempts to add it to the BODY (document.body.appendChild(newElem)) element before the closing BODY tag has been encountered by the parser. Note that if I removed the highlighted DIV element, then this problem would not occur because the script block’s immediate parent would be BODY, and the script block’s immediate parent is immune to this problem.
Unfortunately the operation aborted dialog was always thrown at the top-level of a web page, even if the problem occured in an iframe. In fact, in most scenarios that we encountered, ad injection in an iframe was usually the root cause of this error. After the user dismissed the error dialog, Internet Explorer would navigate away from the page.

Selenium RC drops error when it tries open the popup

When selenium tries to open popup window I'm getting JS error permission denied in file
file:///C:/DOCUME~1//LOCALS~1/Temp/customProfileDir8708f7f69e14482ba857f4b2e74775c1/core/RemoteRunner.hta
So this break script execution, could you assist? I saw a related topic at MSDN and openqa but didn't find resolution that could help me.
I've just encountered this error. In the end it was because I was running IE in 'Offline' mode. Open the File menu and make sure that "Work Offline" does not have a tick next to it.
I've just updated a section about that in the Selenium docs. The website build is not working right now, so if you go to the site you will find the old version.
I'll paste the raw text here, I think your case is the second: JS trying to access sections that are still not loaded, so your solution would be a waitForPopUp command:
Why am I getting a permission denied
error?
The most common reason for this error
is that your session is attempting to
violate the same-origin policy by
crossing domain boundaries (e.g.,
accesses a page from http://domain1
and then accesses a page from
http://domain2) or switching protocols
(moving from http://domainX to
https://domainX). For this to be
solved, try using the Heightened
Privileges Browsers if you're working
with the Proxy Injection browsers.
This is covered in some detail in the
tutorial. Make sure you read the
sections about The Same Origin Policy
and Proxy Injection carefully.
If the previous situation was not your
case, it can also occur when
JavaScript attempts to look at
objects which are not yet available
(before the page has completely
loaded), or tries to look at objects
which are no longer available (after
the page has started to be unloaded).
This is most typically encountered
with AJAX pages which are working with
sections of a page or subframes that
load and/or reload independently of
the larger page. For this type of
problem, it is common that the error
is intermittent. Often it is
impossible to reproduce the problem
with a debugger because the trouble
stems from race conditions which are
not reproducible when the debugger's
overhead is added to the system. Try
first adding a static pause to make
sure this is the situation and then
moving on to the waitFor kind of
commands.