javascript - Proper way to limit wait time on selenium element search -


my nightwatch/selenium test code looks elements in page may not exist using code such

browser.elementidelement(element,'class name', 'myclass', function(r) {   if (r.status == 0) console.log('found match')     else               console.log('did not find match') }) 

if element found, callback invoked (< 50ms), if no element matches, callback takes longer (>1000ms). have hundreds of times , there few elements match search criteria, adds significant amount of time test run.

i limit time selenium spends searching elements. tried using selenium timeoutsimplicitwait() function, e.g.,

browser.timeoutsimplicitwait(250)        .elementidelement(element,'class name', 'myclass', function(r) {...}) 

but doesn't affect performance. correct method limiting element search time?

perhaps misunderstanding problem; both of these patterns works me:

client .usexpath().waitforelementpresent(selector, this.timeout) .usecss().waitforelementpresent(selector, this.timeout) 

this.timeout set in prototype of base test case.

util.inherits(myexamplebaseclass, base);  myexamplebaseclass.prototype = {   before: function (client) {     // call super-before     base.prototype.before.call(this, client);     this.timeout = 250;   },    after: function (client, callback) {     // call super-after     base.prototype.after.call(this, client, callback);   },    // note: method not mistaken nightwatch step because   // not enumerable (since it's on prototype)   getsiteurl: function () {     return "http://www.urlundertest.com/";   } }; 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -