selenium - waitForCondition gives missing ; before statement error -
i've looked @ examples , still have problem using waitforcondition. here code.
webdriverbackedselenium seleniumwd = new webdriverbackedselenium(driver, "http://www.x.com"); seleniumwd.waitforcondition("seleniumwd.iselementpresent(\"fullname\");", "5000"); i error: seleniumwd not defined. changed to:
webdriverbackedselenium seleniumwd = new webdriverbackedselenium(driver, "http://www.x.com"); seleniumwd.waitforcondition("boolean ok = seleniumwd.iselementpresent(\"fullname\");", "5000"); and error: missing ; before statement
it seems using selenium js object selenium 2/ webdriver based test. instead of using webdriverbackedselenium should use expectedcondition , wait classes provided webdriver. in case, assuming fullname id of element waiting, code should this:
webelement element; expectedcondition<boolean> e = new expectedcondition<boolean>() { public boolean apply(webdriver d) { element = d.findelement(by.id("fullname")); return boolean.true; } }; wait<webdriver> w = new webdriverwait(driver, timeoutinseconds); w.until(e); this big piece of code, should consider utilizing page objects pattern 1 of best practices writing selenium tests. example page contains field this:
public class mypage { @findby(id="fullname") private webelement fullname; public mypage(webdriver driver) { pagefactory.initelements(new ajaxelementlocatorfactory(driver, 15), this); } public void setfullname(string value) { fullname.clear(); fullname.sendkeys(value); } }
Comments
Post a Comment