javascript - What are the inner workings of the Selenium waitFor mechanism? -


i trying customize behavior of selenium's click command, (via user-extentions.js), intercepting calls doclick(locator). need delay click actions whenever our application's "busy indicator" being displayed.

(now standard answer kind of thing insert waitfor script situations. indeed, have zillions of them throughout our scripts. i'm trying eliminate those.)

detecting page element trivial part. tricky part getting script wait. promising looking, failed attempt looks this:

var nativeclick = selenium.prototype.doclick; selenium.prototype.doclick = function(locator) {   this.dowaitforcondition("!selenium.browserbot.findelementornull('busy-indicator')", 5000);   return nativeclick.call(this, locator); } 

the dowaitforcondition gets called before every click, not wait when condition evaluates false. nativeclick gets called immediately, , no delay introduced. suspect dowaitforcondition function doesn't waiting per se, rather establishes conditions within command execution loop. , in case click command in play, , i'm trying run command within command.

can shed light on how selenium command execution , waitfor works, or offer suggestions on how might done?

i have solved this. , approach better trying intercept click processing in various forms. refined goal is: delay execution of script command completion when our application "busy".

how selenium command processing works:

upon completion, each selenium command returns actionresult object, (see actionhandler.prototype.execute). terminationcondition attribute on object function determines when okay selenium proceed next command, (testloop.prototype.continuetestwhenconditionistrue). basically, selenium repeatedly executes condition function until yields true. result object quite trivial:

function actionresult(terminationcondition) {   this.terminationcondition = terminationcondition; } 

customizing it:

i want delay execution time myappisbusy() returns true. of course of standard delays need remain in place well, waiting page loads, , explicit waitfor conditions scripted. solution redefine selenium result object in user-extensions.js, follows:

function actionresult(terminationcondition) {   this.terminationcondition = function() {     // null terminationcondition means okay continue     return (!terminationcondition || terminationcondition()) && !myappisbusy();   } } 

the great thing @ low enough level works ide, rc.

note not affect accessor or assert command types, return different result objects. should fine, because commands don't effect state of application.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -