selenium webdriver - Not able to run automation test on windows 10 edge looks like jquery selector is not working -
i trying run automation tests on windows 10 edge , @ moment it's not able create jquery element , return element can perform actions on (like sendkeys or click on etc...) below sample flow of test. check jquery exists or not if doesn't inject http://code.jquery.com/jquery-1.10.1.min.js last block of code have included here.
if (localdriver.equals("internetexplorer")) { edgeoptions options = new edgeoptions(); options.pageloadstrategy = edgepageloadstrategy.eager; driver = new edgedriver("c:\\program files (x86)\\microsoft web driver", options); driver.url = urlhelper.homeurl; driver.navigate().gotourl("javascript:document.getelementbyid('overridelink').click()"); } this._context.driver.manage().window.maximize(); if (this.deleteallcookies) this._context.driver.manage().cookies.deleteallcookies(); driver.usernametextfield.clear(); --- statement has use below statement , create web element internal webcontrol ticketidtextfield { { return this.createcontrol("#ticketid"); } } #region create control public webcontrol createcontrol(string jqueryselector) { return this.createcontrol<webcontrol>(jqueryselector); } public t createcontrol<t>(string jqueryselector) t : webcontrol { return this.createcontrol<t>(webcontrol.searchnames.jqueryselector, jqueryselector); } public new t createcontrol<t>(params string[] namevaluepairs) t : webcontrol { return base.createcontrol<t>(namevaluepairs); } public new t createcontrol<t>(ienumerable<searchproperty> searchproperties) t : webcontrol { return base.createcontrol<t>(searchproperties); } #endregion #region create control public t createcontrol<t>(params string[] namevaluepairs) t : control { if ((namevaluepairs.length % 2) != 0) { throw new argumentexception("createcontrol needs have number of pairs. (mod 2)", "namevaluepairs"); } var searchproperties = new list<searchproperty>(); (int = 0; < namevaluepairs.length; = (int)(i + 2)) { searchproperties.add(new searchproperty(namevaluepairs[i], namevaluepairs[i + 1])); } return this.createcontrol<t>(searchproperties); } public virtual t createcontrol<t>(ienumerable<searchproperty> searchproperties) t : control { var control = control.createinstance<t>(this.context, this); control.searchproperties.addrange(searchproperties); return control; } #endregion #region rawcontrol private object _rawcontrol; public object rawcontrol { { /* search feature * --------------------- * * if there property in search properties * set "always search" must call this.find() * * if global property set search, * must call this.find() * */ var alwayssearch = this.searchproperties.any(x => x.name == control.searchnames.alwayssearch); if (this._rawcontrol == null || (this._ishightlighting == false && (playback.alwayssearch || alwayssearch))) { this.find(); } return this._rawcontrol; } } public object executescript(string script, params object[] args) { var javascriptexecutor = (ijavascriptexecutor)this.driver; if(checkjqueryexists) { var timeout = timespan.fromseconds(60); var timeoutthreshold = datetime.utcnow.add(timeout); var isjqueryundefined = new func<bool>(() => (bool)javascriptexecutor.executescript("return (typeof $ === 'undefined')")); if (isjqueryundefined()) { javascriptexecutor.executescript(@" var scheme = window.location.protocol; if(scheme != 'https:') scheme = 'http:'; var script = document.createelement('script'); script.type = 'text/javascript'; script.src = scheme + '//code.jquery.com/jquery-1.10.1.min.js'; document.getelementsbytagname('head')[0].appendchild(script); "); while (isjqueryundefined()) { system.threading.thread.sleep(200); //don't test forever.. bomb out after bit. if (datetime.utcnow > timeoutthreshold) throw new timeoutexception(string.format("checking jquery exists timed out after {0} seconds.", timeout.totalseconds)); } } } return javascriptexecutor.executescript(script, args); } driver.username="someuser";
Comments
Post a Comment