public void WaitForCustomFunction_WithLoad() { HtmlPage page = new HtmlPage(); page.Navigate("HTMLPage1.htm"); page.Elements.Find("Button1").Click(); string expression = @" function foo() { if(document.getElementById('Messages').innerHTML == 'MyCodeMarker') { return true; } else { return false; } }"; page.ExecuteScript(expression); page.WaitForScript("foo()", 10); Assert.AreEqual("MyCodeMarker", page.Elements.Find("Messages").GetInnerText()); }
public void ExecuteScriptOnPageAndGetReturnValue() { HtmlPage page = new HtmlPage("ScriptSamples.aspx"); // Call script that exists in the ScriptSamples.aspx page and get return value string value = (string) page.ExecuteScript("GetValueFromScript()"); // Verify return value from script Assert.AreEqual("Value from script", value); }
public void ExecuteScriptOnPage() { HtmlPage page = new HtmlPage("ScriptSamples.aspx"); // Execute script in the context of the ScriptSamples.aspx page page.ExecuteScript("document.getElementById('Span2').innerHTML = 'Operation Complete on Span2.';"); // Verify span Assert.AreEqual("Operation Complete on Span2.", page.Elements.Find("Span2").GetInnerText()); }
public void ExecuteScriptOnPageAndGetReturnValue() { HtmlPage page = new HtmlPage("ScriptSamples.aspx"); // Call script that exists in the ScriptSamples.aspx page and get return value string value = (string)page.ExecuteScript("GetValueFromScript()"); // Verify return value from script Assert.AreEqual("Value from script", value); }