Forum Discussion

Oleg's avatar
Oleg
Occasional Contributor
14 years ago

Unspecified error while trying to check readyState property

Hi all!



I'd like to share one problem, that sometimes appears and brakes our tests during their execution. In general - we get only short "Unspecified error" in the logs and tests are stopped. It seems this error is caused by trying to check the readyState property of the document object (document is child of Page() here). This issue is not easy reproducible - we get this error time from time and it's really difficult to somehow track specific conditions, that might have impact on it. Before checking the property, we use aqObject.isSupported(document, "readyState"), but anyway time from time tests are stopped due to this issue.



So, I wonder if someone has already faced this error or some similar problem? I'd appreciate any thoughts/ideas, because it's really annoying
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Oleg,


    The error can occur because the brwoser destroys the document object and replaces it with another one.

    Consider the following situation:


        // You get a reference to the document object

        var document = ...

        // Then you open a new page

        Page.ToURL("....")

        // Check the document's properties

        while (document.readyState ... )// <-- An error will occur as the browser created another document for the new page.


    You wrote that the error occurred from time to time, so I suppose that you call ToURL and then obtain the document object for the loaded page:


        // Open a new page

        Page.ToURL("....")

        // Get a reference to the document object

        document = ...

        // Check properties

        while ( document.readyState ... )


    However, in certain cases the web browser can start navigation with some delay, that is, some delay occurs after you call the ToURL method and before the navigation actually starts. So, ToURL returns a reference to the "old" Page object. Perhaps, this is what happends in your case. To check this, I suggest that you insert a call to the WaitPage method after ToURL to pause the test execution until the page becomes available.