Part 2 series of calling java script code in C# Selenium
Part 2 series of calling java script code in C# Selenium .Below sample code is helpful in synchronization of page loads with Explicit Wait conditions.
Document Ready State :-
Webdriver.Navigate().GoToUrl("http://www.google.com");
IJavaScriptExecutor js = Webdriver as IJavaScriptExecutor;
string readyState = (string) js.ExecuteScript("return document.readyState");
Console.WriteLine("Ready State is {0}",readyState);
Verify if Jquery is available on the webpage :-
IJavaScriptExecutor js = Webdriver as IJavaScriptExecutor;
jQueryNotLoaded = (bool)js.ExecuteScript("return typeof jQuery == 'undefined' ");
jQueryNotLoaded is true when jquery is not used on the webpage .
(or)
IJavaScriptExecutor js = Webdriver as IJavaScriptExecutor;
jQueryLoaded = (bool)js.ExecuteScript("return window.jQuery ");
jQueryLoaded is true when jquery is available on the webpage.
IJavaScriptExecutor js = Webdriver as IJavaScriptExecutor;
jQueryNotLoaded = (bool)js.ExecuteScript("return jQuery.active == 0 ");
Very nice blog... code analysis tools C# is also very helpful tool for code analysis
ReplyDelete