本文整理汇总了C#中IE.RunScript方法的典型用法代码示例。如果您正苦于以下问题:C# IE.RunScript方法的具体用法?C# IE.RunScript怎么用?C# IE.RunScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IE
的用法示例。
在下文中一共展示了IE.RunScript方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseSpecificBrowserAlert
public void CloseSpecificBrowserAlert()
{
Assert.AreEqual(0, Ie.DialogWatcher.Count, "DialogWatcher count should be zero");
var firstIE = Ie;
firstIE.RunScript("document.title = 'firstIe'; ");
using (var secondIe = new IE(TestPageUri,true))
{
secondIe.RunScript("document.title = 'secondIe'; ");
// set up a second browser with an open dialog
var secondAlertDialogHandler = new AlertDialogHandler();
using (new UseDialogOnce(secondIe.DialogWatcher, secondAlertDialogHandler))
{
secondIe.Button(Find.ByValue("Show alert dialog")).ClickNoWait();
secondAlertDialogHandler.WaitUntilExists(5);
// close the original message
var firstAlertDialogHandler = new AlertDialogHandler();
using (new UseDialogOnce(firstIE.DialogWatcher, firstAlertDialogHandler))
{
firstIE.Button(Find.ByValue("Show alert dialog")).ClickNoWait();
firstAlertDialogHandler.WaitUntilExists(5);
var message = firstAlertDialogHandler.Message;
firstAlertDialogHandler.OKButton.Click();
firstIE.WaitForComplete(5);
Assert.IsTrue(secondAlertDialogHandler.Exists(), "Original Alert Dialog should be open.");
Assert.AreEqual("This is an alert!", message, "Unexpected message");
Assert.IsFalse(firstAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
}
// close the second message
secondAlertDialogHandler.OKButton.Click();
secondIe.WaitForComplete(5);
Assert.IsFalse(secondAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
}
}
}