Пример #1
0
        public void HtmlInputButton_UsingSearchParameterWithValueAsKey_Succeeds()
        {
            //Internet Explorer may display the message: Internet Explorer restricted this webpage from running scripts or ActiveX controls.
            //This security restriction prevents the alert message to appear.
            //To enable running scripts on the local computer, go to Tools > Internet options > Advanced > Security > [checkmark] Allow active content to run in files on My Computer

            //Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <input type=""submit"" value=""Log In"" onclick=""alert('onclick');""/>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlInputButton button = window.Get <EnhancedHtmlInputButton>("Value=Log In");

                //Act
                button.Click();

                if (WebPage.GetCurrentBrowser() is InternetExplorer)
                {
                    //read JavaScript alert text
                    var             popup = new EnhancedWinWindow("ClassName=#32770;Name=Message from webpage");
                    EnhancedWinText text  = popup.Get <EnhancedWinText>();
                    Assert.AreEqual("onclick", text.DisplayText);
                }

                window.PerformDialogAction(BrowserDialogAction.Ok);

                window.Close();
            }
        }
        public void HtmlInputButton_UsingSearchParameterWithValueAsKey_Succeeds()
        {
            //Internet Explorer may display the message: Internet Explorer restricted this webpage from running scripts or ActiveX controls.
            //This security restriction prevents the alert message to appear.
            //To enable running scripts on the local computer, go to Tools > Internet options > Advanced > Security > [checkmark] Allow active content to run in files on My Computer

            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <input type=""submit"" value=""Log In"" onclick=""alert('onclick');""/>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlInputButton button = window.Get<EnhancedHtmlInputButton>("Value=Log In");

                //Act
                button.Click();

                if (WebPage.GetCurrentBrowser() is InternetExplorer)
                {
                    //read JavaScript alert text
                    var popup = new EnhancedWinWindow("ClassName=#32770;Name=Message from webpage");
                    EnhancedWinText text = popup.Get<EnhancedWinText>();
                    Assert.AreEqual("onclick", text.DisplayText);
                }

                window.PerformDialogAction(BrowserDialogAction.Ok);

                window.Close();
            }
        }