public Dictionary <string, object> GetAttributes(JScriptType jScriptType, IWebDriver webDriver, IWebElement webElement) { IJavaScriptExecutor js = (IJavaScriptExecutor)webDriver; Dictionary <string, Object> Attribute = new Dictionary <string, object>(); Attribute = (Dictionary <string, Object>)js.ExecuteScript(jScriptType.GetDescription(), webElement); return(Attribute); }
// constructorb - only one no overloads public JServer(JScriptType jLoadType, params string[] jScripts) { try { this.jSetup(jLoadType, jScripts); } catch { throw; } }
private void jSetup(JScriptType jsType, params string[] jScripts) { try { // default setup jProfile(); if (jsType == JScriptType.OnlyProfile) { return; } string loadpfx = ""; if (JScriptType.Noun == jsType) { // load nouns (strings of j code) loadpfx = NOUNLOAD + TMPS; foreach (string str in jScripts) { jSet(TMPS, str); jLoad(loadpfx); jDo(CLEARTMPS); } return; } if (JScriptType.Library == jsType) { loadpfx = LIBLOAD; } else if (JScriptType.Script == jsType) { loadpfx = SCRIPTLOAD; } else { string jerr = "invalid j load script"; Exception eoe = new Exception(jerr); throw eoe; } // load libraries or script files foreach (string scr in jScripts) { jLoad(loadpfx + scr + SQUOTE); } } catch { throw; } }
public void jLoad(JScriptType jsType, string jScript) { try { if (jsType == JScriptType.OnlyProfile) { return; } string loadpfx = (jsType == JScriptType.Library) ? LIBLOAD : SCRIPTLOAD; jLoad(loadpfx + jScript + SQUOTE); } catch { throw; } }
public object ExecuteScript(JScriptType jScriptType, IWebDriver webDriver, IWebElement webElement) { try { return(((IJavaScriptExecutor)webDriver).ExecuteScript(jScriptType.GetDescription(), webElement)); } catch (InvalidOperationException ObjInvalidOperationException) { Logger.Error("WaitTillAjaxLoad threw InvalidOperationException with message '{0}'", ObjInvalidOperationException.Message); return(null); } catch (WebDriverTimeoutException ObjWebDriverTimeoutException) { Logger.Error(String.Format("Error: Exception thrown while running JS Script:{0}{1}{2}", Environment.NewLine, jScriptType.GetDescription(), ObjWebDriverTimeoutException.Message)); return(null); } catch (Exception ObjException) { Logger.Error(String.Format("Error: Exception thrown while running JS Script:{0}", Environment.NewLine, ObjException.Message)); return(null); } }
public void ScrollTop(JScriptType jScriptType, IWebDriver webDriver) { ExecuteScript(JScriptType.ScrollTop.GetDescription(), webDriver); WaitTillAjaxLoad(webDriver); }