javascript - Does WebdriverJS wait() return a web element? -
i'm trying use webdriverjs wait() method in page objects make sure time access element, webdriver wait until present. currently, code have "looks" correct, won't let me click element once it's returned wait(). based on research i've done, looks there have been others have been able of yet have not been able figure out.
i getting error: typeerror: undefined not function - on element.click()
method in page object:
facilitypage.prototype.selectfacility = function (facilityname) { var self = this; this.driver.wait(function () { return self.driver.iselementpresent(by.linktext(facilityname)).then(function (elm) { console.log('this elm: ', elm); return elm; }); }, 10000).then(function (element) { element.click(); }); };
how call test file:
facilitypage.selectfacility('facility 1');
protractor had breaking change in 2.0 killed way of testing availability. new hotness expectedconditions. here's how might handle case...
if have basepage (if not page), set expected condition (i rename them bit more useful):
var ec = protractor.expectedconditions; this.isclickable = function(locator) { return ec.elementtobeclickable(locator); };
i use general purpose waitandclick
er, heart of we're talking here.
this.waitandclick = function(element) { browser.wait(this.isclickable(element), 5000).then(function() { element.click(); }); };
then in page object, handle specific case.
facilitypage.prototype.selectfacility = function (facilityname) { this.waitandclick(element(by.linktext(facilityname))); };
call same way...
facilitypage.selectfacility('facility 1');
Comments
Post a Comment