java - Handling self-refreshing pages from selenium -
I am running intermittent errors with some Java selenium-RC test which I think relates to a page in which An AJAX survey and automatically refreshes when certain conditions reach the server. In this scenario, there is no way to ask Selenium to wait for the page to load, and so I went into a bunch of errors, "Can not use the body of the document."
So, is there some way I can handle Selenium in this situation beautifully? If not, can I find that the user is selenium from JavaScript on the page and can disable auto refresh?
If it does help, then JavaScript code looks something like this in the page ..
var ajax = new Ajax (URL, {update: state, method: 'received', absolute function (message) {if (some condition) {window.location.replace (unescape (Window .location));}}});
One solution is to always use waitForCondition
Before trying to interact with the application under the exam, you can put the following method in a superclass to keep your tests more readable. Alternatively, you can make useful ways for normal Selenium commands which are waiting for it.
/ ** Waiting for one element * / Public Static Wait for zero Falconnature tab (string locator) {Session (WaiterCondition ("var value = selenium.isElementPresent ('" + "+ Locator.replace ("", "\\ '" + "' '); value == true", "60000");}
You also wait to see the element As it is not just waiting to be present (always imagine a text box, which is always present but unless a certain You can add it to the above method:
/ ** Waiting for one element * / Public Static Zero WaitFillmentTobweaver (String Locator) {waitForElementToBePresent (Locator ); Session (). WaitForCondition ("var value = selenium.isVisible ('" + locator.replace ("", "\\'" + "'); value == true", TIMEOUT);}
Incidentally, WebDriver (Selenium 2) team is working on waiting for interception, especially to solve issues of AJX The elements are not present immediately.
Comments
Post a Comment