Exemplo n.º 1
0
        public void ExecuteCommand_ShouldSendsTracesOnlyForNextCommand()
        {
            //arrange
            MockCommandExecutor commandExec = new MockCommandExecutor();

            commandExec.SetBrowserInfo(new BrowserInfo()
            {
                Data = "<html><body>Hello</body></html>"
            });
            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExec);

            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("http://test");
            var testPage = new HtmlPage();

            //act
            WebTestConsole.Clear();
            WebTestConsole.Write("foo");
            WebTestConsole.Write("bar");

            testPage.Elements.Refresh();

            //assert
            UnitTestAssert.AreEqual("GetPageDom", commandExec.ExecutedCommands[0].Handler.ClientFunctionName);
            UnitTestAssert.AreEqual(2, commandExec.ExecutedCommands[0].Traces.Length);
            UnitTestAssert.AreEqual("foo", commandExec.ExecutedCommands[0].Traces[0]);
            UnitTestAssert.AreEqual("bar", commandExec.ExecutedCommands[0].Traces[1]);

            //act
            testPage.Elements.Refresh();

            //assert
            UnitTestAssert.AreEqual(0, commandExec.ExecutedCommands[1].Traces.Length);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Default entry into managed code.
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task <object> Invoke(object input)
    {
        if (console == null)
        {
            console = await WebSharpJs.NodeJS.Console.Instance();
        }

        try
        {
            var document = await HtmlPage.GetDocument();

            var info = await HtmlPage.GetBrowserInformation();

            var infoText = $"Name: {info.Name}<br />Browser Version: {info.BrowserVersion}<br />Platform: {info.Platform}<br />Cookies Enabled: {info.CookiesEnabled}<br />User Agent: {info.UserAgent}";

            var paragraph = await document.GetElementById("info");

            await paragraph.SetProperty("innerHTML", infoText);

            await console.Log($"Hello:  {input}");
        }
        catch (Exception exc) { await console.Log($"extension exception:  {exc.Message}"); }

        return(null);
    }
Exemplo n.º 3
0
        public void NewTestPageHasNoElements()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/test");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual(0, page.Elements.Count);
        }
Exemplo n.º 4
0
        public void CanAccessElementsOnThePage()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/test");
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);

            string html = @"
                <html id='control1'>
                    <foo id='control2'> 
                        <bar id='control3' />
                    </foo>
                </html>
                ";

            BrowserInfo browserInfo = new BrowserInfo();

            browserInfo.Data = html;
            commandExecutor.SetBrowserInfo(browserInfo);

            HtmlPage page = new HtmlPage();

            page.Elements.Refresh();
            UnitTestAssert.AreEqual("html", page.RootElement.TagName);
            UnitTestAssert.AreEqual("foo", page.Elements.Find("control2").TagName);
        }
Exemplo n.º 5
0
        public void ResolveNavigateUrlAppendsUrlToApplicationPath()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/foo");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual("/foo/bar", page.ResolveNavigateUrl("bar"));
        }
Exemplo n.º 6
0
        public void ResolveNavigateUrlDoesntAddExtraSlash()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/foo");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual("/foo/bar", page.ResolveNavigateUrl("/bar"));
        }
Exemplo n.º 7
0
        public void ResolveNavigateUrlToRootWhenEmpty()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/foo");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual("/foo", page.ResolveNavigateUrl(""));
        }
Exemplo n.º 8
0
        public void ResolveNavigateUrlWithAbsoluteVale()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/foo");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual("http://bar", page.ResolveNavigateUrl("http://bar"));
        }
Exemplo n.º 9
0
        public void ResolveNavigateUrlInCassini()
        {
            ServiceLocator.ApplicationPathFinder = new ApplicationPathFinder("/");
            HtmlPage page = new HtmlPage();

            UnitTestAssert.AreEqual("/bar", page.ResolveNavigateUrl("/bar"));
        }
Exemplo n.º 10
0
        private void runSim_Click(object sender, RoutedEventArgs e)
        {
            int openSockets = SocketReader.checkOpenSocks(editorDragDrop.getTreeList());

            //cannot continue if a socket is open
            if (openSockets > 0)
            {
                MessageBoxButton button = MessageBoxButton.OK;                                                            //only allow OK and X buttons
                MessageBoxResult result = MessageBox.Show("Cannot Execute: There are unfilled sockets", "Error", button); //display message window
                return;
            }

            IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();

            if (iso.FileExists("test.txt"))
            {
                iso.DeleteFile("test.txt");
            }
            CodeParser.writeToFile("{");
            CodeParser.parseVariable(variableList, editorDragDrop);
            CodeParser.parseCode(editorDragDrop);
            CodeParser.writeToFile("\n");
            CodeParser.parseMethods(methodList, tabList);
            CodeParser.writeToFile("}");
            HtmlPopupWindowOptions options = new HtmlPopupWindowOptions();

            options.Width  = 1000;
            options.Height = 1000;
            HtmlPage.PopupWindow(new Uri("http://webstrar44.fulton.asu.edu/page3/RobotSim/launch.jnlp"), "_blank", options);
            messageWindow();
        }
        public ScriptableSilverlight()
        {
            InitializeComponent();

            HtmlPage.RegisterScriptableObject("Page", this);
            HtmlPage.RegisterCreateableType("RandomNumbers", typeof(RandomNumbers));
        }
Exemplo n.º 12
0
    public void CreateUserAndSignOut()
    {
        // Navigate to the login page
        HtmlPage page = new HtmlPage("Login.aspx");

        // Click on the link to toggle divs
        page.Elements.Find("a", "Not a member?", 0).Click();

        // Get a hold of the element that represents the CreateUserWizard
        HtmlElement createUserWizard = page.Elements.Find("CreateUserWizard1");

        // Fill control and click the next step button
        createUserWizard.ChildElements.Find("UserName").SetText("NewValidUser");
        createUserWizard.ChildElements.Find("Password").SetText("foo");
        createUserWizard.ChildElements.Find("ConfirmPassword").SetText("foo");
        createUserWizard.ChildElements.Find("Email").SetText("*****@*****.**");
        createUserWizard.ChildElements.Find("StepNextButton").Click(WaitFor.Postback);

        // Verify content of the Home page
        Assert.AreEqual("Welcome back NewValidUser!", page.Elements.Find("LoginName1").GetInnerText());

        // Click the signout tab
        page.Elements.Find("tab-signout").Click(WaitFor.Postback);

        // Verify sign in tab is now present
        Assert.IsTrue(page.Elements.Exists("tab-login"));
    }
Exemplo n.º 13
0
    public void GridViewEditTest()
    {
        HtmlPage page = new HtmlPage();
        LoginAndGoToHome(page);

        // Build the expected grades that are going to be set
        Random rand = new Random(DateTime.Now.Second);
        string grade1 = rand.Next(100).ToString();
        string grade2 = rand.Next(100).ToString();
        string grade3 = rand.Next(100).ToString();

        // Get the gridview table
        HtmlTableElement gridView = (HtmlTableElement)page.Elements.Find("CoursesGridView");

        // Go to edit mode
        gridView.Rows[1].Cells[1].ChildElements[0].Click(WaitFor.AsyncPostback);

        // Fill the textboxes
        gridView.ChildElements.Refresh();
        gridView.Rows[1].Cells[6].ChildElements[0].SetText(grade1);
        gridView.Rows[1].Cells[7].ChildElements[0].SetText(grade2);
        gridView.Rows[1].Cells[8].ChildElements[0].SetText(grade3);

        // Click update button
        gridView.Rows[1].Cells[1].ChildElements[0].Click(WaitFor.AsyncPostback);

        // Verify new values
        gridView.ChildElements.Refresh();
        Assert.AreEqual(grade1, gridView.Rows[1].Cells[6].CachedInnerText);
        Assert.AreEqual(grade2, gridView.Rows[1].Cells[7].CachedInnerText);
        Assert.AreEqual(grade3, gridView.Rows[1].Cells[8].CachedInnerText);
    }
Exemplo n.º 14
0
        private IEnumerable<QUnitTest> GrabTestResultsFromWebPage(HtmlPage testPage)
        {
            var documentRoot = testPage.getElementById("qunit-tests");

            XmlDocument xmlResults = new XmlDocument();
            xmlResults.LoadXml(documentRoot.asXml());

            var results = new List<QUnitTest>();

            foreach (XmlNode result in xmlResults.FirstChild.ChildNodes)
            {

                var resultClass = result.Attributes["class"].Value;

                var testName = result.SelectSingleNode("strong/span[@class='test-name']/text()").Value.Trim();

                var message = "";
                var failMessageItem = result.SelectSingleNode("ol/li[@class='fail']/text()");
                if (failMessageItem != null)
                {

                    message = failMessageItem.Value.Trim();
                }

                yield return new QUnitTest
                {
                    FileName = "",
                    TestName = testName.ToString(),
                    Result = resultClass,
                    Message = message
                };

            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerView"/> class.
        /// </summary>
        public PlayerView()
        {
            InitializeComponent();

            HtmlPage.RegisterScriptableObject("Player", this);
            this.timer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 1)
            };
            this.timer.Tick   += this.Timer_Tick;
            this.timeCodeTimer = new DispatcherTimer {
                Interval = new TimeSpan(500)
            };
            this.timeCodeTimer.Tick         += this.TimeCodeTimer_Tick;
            this.Player.CurrentStateChanged += this.Player_CurrentStateChanged;
            this.Player.MediaOpened         += this.Player_MediaOpened;
            this.Player.ManifestReady       += this.Player_ManifestReady;
            this.Loaded += this.PlayerView_Loaded;

            this.commentsVisibility = Visibility.Visible;

            // Key Commands
            if (Application.Current.RootVisual != null)
            {
                Application.Current.RootVisual.KeyDown += this.RootVisual_KeyDown;
            }
        }
Exemplo n.º 16
0
        public void HtmlPage_CompositionSample()
        {
            var target = new HtmlPage
            {
                Title = "Test Page",
                Head =
                {
                    new Html.Link
                    {
                        Href = "../test.css",
                        Rel = "stylesheet"
                    },
                    new Html.EncodedText("    ")
                },
                Body =
                {
                    new Html.Div
                    {
                        Elements =
                        {
                            new Html.H1 { Elements = { new Html.EncodedText("Heading 1") } }
                        }
                    }
                }
            };

            Assert.AreEqual(2, target.Head.Count);
            Assert.AreEqual(1, target.Body.Count);
        }
Exemplo n.º 17
0
        public void RegisterScriptableObject()
        {
            PublicScriptable instance = new PublicScriptable();

            Assert.Throws <ArgumentNullException> (delegate {
                HtmlPage.RegisterScriptableObject(null, instance);
            }, "null,instance");
            Assert.Throws <ArgumentException> (delegate {
                HtmlPage.RegisterScriptableObject(String.Empty, instance);
            }, "Empty,instance");
            Assert.Throws <ArgumentException> (delegate {
                HtmlPage.RegisterScriptableObject("a\0b", instance);
            }, "string-with-null,instance");

            Assert.Throws <ArgumentNullException> (delegate {
                HtmlPage.RegisterScriptableObject("a", null);
            }, "string,null");

            Assert.Throws <InvalidOperationException> (delegate {
                HtmlPage.RegisterScriptableObject("non-public", new Private());
            }, "string,non-public");
            Assert.Throws <ArgumentException> (delegate {
                HtmlPage.RegisterScriptableObject("no-scriptable-member", new Ok());
            }, "string,no-scriptable-member");
        }
Exemplo n.º 18
0
        public void RegisterScriptableObject_Reserved()
        {
            PublicScriptable instance = new PublicScriptable();

            // reserved *method* (not registration) names
            HtmlPage.RegisterScriptableObject("addEventListener", instance);
            HtmlPage.RegisterScriptableObject("removeEventListener", instance);
            HtmlPage.RegisterScriptableObject("constructor", instance);
            HtmlPage.RegisterScriptableObject("createManagedObject", instance);

            // case sensitive test case
            HtmlPage.RegisterScriptableObject("CONSTRUCTOR-casing", new Scriptable_CONSTRUCTOR());

            // reserved members
            Assert.Throws <InvalidOperationException> (delegate {
                HtmlPage.RegisterScriptableObject("bad-addEventListener", new Scriptable_addEventListener());
            }, "addEventListener,instance");
            Assert.Throws <InvalidOperationException> (delegate {
                HtmlPage.RegisterScriptableObject("bad-removeEventListener", new Scriptable_removeEventListener());
            }, "removeEventListener,instance");
            Assert.Throws <InvalidOperationException> (delegate {
                HtmlPage.RegisterScriptableObject("bad-CONSTRUCTOR", new Scriptable_constructor());
            }, "constructor,instance");
            Assert.Throws <InvalidOperationException> (delegate {
                HtmlPage.RegisterScriptableObject("bad-createManagedObject", new Scriptable_createManagedObject());
            }, "createManagedObject,instance");

            HtmlPage.RegisterScriptableObject("non-scriptable-reserved-names", new NonScriptableReservedNames());
        }
Exemplo n.º 19
0
        public void WhenSubmit_ShouldSendSubmitCommand()
        {
            //arrange
            var html = @"
<html>
    <body>
        <form id='form1'>
            <input type='hidden' id='input1' value='thevalue' />
        </form>
    </body>
</html>";
            MockCommandExecutor commandExecutor = new MockCommandExecutor();

            _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor);

            var testPage = new HtmlPage();
            var document = HtmlElement.Create(html, testPage, false);

            //act
            var form = (HtmlFormElement)document.ChildElements.Find("form1");

            form.Submit();

            //assert
            MSAssert.AreEqual("FormSubmit", commandExecutor.ExecutedCommands[0].Handler.ClientFunctionName);
            MSAssert.AreEqual("FormSubmit", commandExecutor.ExecutedCommands[0].Description);
            MSAssert.IsTrue(commandExecutor.ExecutedCommands[0].Handler.RequiresElementFound);
            MSAssert.AreEqual("form1", commandExecutor.ExecutedCommands[0].Target.Id);
            MSAssert.IsNull(commandExecutor.ExecutedCommands[0].Handler.Arguments);
        }
Exemplo n.º 20
0
        public bool AddHeaders()
        {
            var wrapLog = Log.Call <bool>();

            // ensure we only do this once
            if (MarkAddedAndReturnIfAlreadyDone())
            {
                return(wrapLog("already", false));
            }
            var siteRoot = ServicesFramework.GetServiceFrameworkRoot();

            if (string.IsNullOrEmpty(siteRoot))
            {
                return(wrapLog("no path", false));
            }

            var dnnVersion = DotNetNukeContext.Current.Application.Version.Major;
            var apiRoot    = siteRoot + (dnnVersion < 9
                ? $"desktopmodules/{InpageCms.ExtensionPlaceholder}/api/"
                : $"api/{InpageCms.ExtensionPlaceholder}/");

            var portal = PortalSettings.Current;
            var json   = InpageCms.JsApiJson(
                portal.ActiveTab.TabID,
                siteRoot,
                apiRoot,
                AntiForgeryToken(),
                VirtualPathUtility.ToAbsolute(DnnConstants.SysFolderRootVirtual));

            HtmlPage.AddMeta(InpageCms.MetaName, json);
            return(wrapLog("added", true));
        }
Exemplo n.º 21
0
    /// <summary>
    /// Default entry into managed code.
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task <object> Invoke(object input)
    {
        if (console == null)
        {
            console = await WebSharpJs.NodeJS.Console.Instance();
        }

        try
        {
            var document = await HtmlPage.GetDocument();

            // Get a reference to the top-level <html> element.
            var element = await document.GetDocumentElement();

            // Process the starting element reference
            await ProcessElement(element, 0);

            await console.Log(elementTree);

            await console.Log($"Hello:  {input}");
        }
        catch (Exception exc) { await console.Log($"extension exception:  {exc.Message}"); }

        return(null);
    }
Exemplo n.º 22
0
        public MainPage(IDictionary <string, string> initParams)
        {
            InitializeComponent();

            HandleInitParams(initParams);

            ChoosePlayer();

            HtmlPage.RegisterScriptableObject("MediaElementJS", this);
            if (initParams.ContainsKey("onLoaded"))
            {
                HtmlPage.Window.Invoke(initParams["onLoaded"]);
            }


            RegisterMediaEvents();

            InitDebug();

            InitTimer();

            InitMedia();

            if (!String.IsNullOrEmpty(_readyCallBack))
            {
                try
                {
                    HtmlPage.Window.Eval(String.Format("{0}('{1}')", _readyCallBack, _playerId));
                }
                catch (Exception e)
                {
                    WriteDebug("Error occur while trying to call readyCallBack function:" + e.Message);
                }
            }
        }
Exemplo n.º 23
0
        public void HtmlPage_RenderTest1()
        {
            HtmlPage page = new HtmlPage
            {
                Title = "Test Title",
                Head =
                {
                    new Html.Link { Href = "Style.css", Rel = "stylesheet" }
                },
                Body =
                {
                    new Html.H1 { Elements = { new Html.EncodedText("Title") } },
                    new Html.P { Elements = { new Html.EncodedText("Text.") } }
                }
            };

            StringBuilder output = new StringBuilder();
            using (HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(output)))
            {
                page.Render(writer);
            }

            string outputText = output.ToString();
            Assert.IsTrue(outputText.Contains("<title>\r\n\t\t\tTest Title\r\n\t\t</title>"));
            Assert.IsTrue(outputText.Contains("<h1>\r\n\t\t\tTitle\r\n\t\t</h1>"));
            Assert.IsTrue(outputText.Contains("<p>Text.</p>"));
        }
Exemplo n.º 24
0
    public void GridViewEditTest()
    {
        HtmlPage page = new HtmlPage();

        LoginAndGoToHome(page);

        // Build the expected grades that are going to be set
        Random rand   = new Random(DateTime.Now.Second);
        string grade1 = rand.Next(100).ToString();
        string grade2 = rand.Next(100).ToString();
        string grade3 = rand.Next(100).ToString();

        // Get the gridview table
        HtmlTableElement gridView = (HtmlTableElement)page.Elements.Find("CoursesGridView");

        // Go to edit mode
        gridView.Rows[1].Cells[1].ChildElements[0].Click(WaitFor.AsyncPostback);

        // Fill the textboxes
        gridView.ChildElements.Refresh();
        gridView.Rows[1].Cells[6].ChildElements[0].SetText(grade1);
        gridView.Rows[1].Cells[7].ChildElements[0].SetText(grade2);
        gridView.Rows[1].Cells[8].ChildElements[0].SetText(grade3);

        // Click update button
        gridView.Rows[1].Cells[1].ChildElements[0].Click(WaitFor.AsyncPostback);

        // Verify new values
        gridView.ChildElements.Refresh();
        Assert.AreEqual(grade1, gridView.Rows[1].Cells[6].CachedInnerText);
        Assert.AreEqual(grade2, gridView.Rows[1].Cells[7].CachedInnerText);
        Assert.AreEqual(grade3, gridView.Rows[1].Cells[8].CachedInnerText);
    }
Exemplo n.º 25
0
        public void AddRemoveHandlerTest()
        {
            object o, result;

            try {
                HtmlPage.RegisterCreateableType("eventCalculator", typeof(EventCalculator));

                o = window.Eval("scriptabletest_addeventhandler_1_result = 0;");
                o = window.Eval("scriptabletest_addeventhandler_2_result = 0;");
                o = window.Eval(@"
scriptabletest_addeventhandler_1_eventhandler = 
function (sender, args) {
	scriptabletest_addeventhandler_1_event_raised = true;
	scriptabletest_addeventhandler_1_result = args.Result;
}");
                o = window.Eval(@"
scriptabletest_addeventhandler_2_eventhandler = 
function (sender, args) {
	scriptabletest_addeventhandler_2_event_raised = true;
	scriptabletest_addeventhandler_2_result = args.Result;
}");
                o = window.Eval("scriptable = " + strplugin + ".content.services.createObject ('eventCalculator');");
                o = window.Eval("scriptable.addEventListener ('DoneEvent', scriptabletest_addeventhandler_1_eventhandler);");
                o = window.Eval("scriptable.addEventListener ('Done2Event', scriptabletest_addeventhandler_2_eventhandler);");
                o = window.Eval("scriptable.Add (1, 2);");

                o = window.GetProperty("scriptabletest_addeventhandler_1_event_raised");
                Assert.IsInstanceOfType(o, typeof(bool), "#1 return type");
                Assert.IsTrue((bool)o, "#1 event raised");
                result = window.GetProperty("scriptabletest_addeventhandler_1_result");
                Assert.IsInstanceOfType(result, typeof(double), "#1 result type");
                Assert.AreEqual((double)result, 3.0, "#1 result");


                o = window.GetProperty("scriptabletest_addeventhandler_2_event_raised");
                Assert.IsInstanceOfType(o, typeof(bool), "#1.2 return type");
                Assert.IsTrue((bool)o, "#1.2 event raised");
                result = window.GetProperty("scriptabletest_addeventhandler_2_result");
                Assert.IsInstanceOfType(result, typeof(double), "#1.2 result type");
                Assert.AreEqual((double)result, 3.0, "#1.2 result");

                o = window.Eval("scriptabletest_addeventhandler_1_event_raised = false;");

                o = window.GetProperty("scriptabletest_addeventhandler_1_event_raised");
                Assert.IsInstanceOfType(o, typeof(bool), "#2 return type");
                Assert.IsFalse((bool)o, "#2 event raised");

                o = window.Eval("scriptable.removeEventListener ('DoneEvent', scriptabletest_addeventhandler_1_eventhandler);");
                o = window.Eval("scriptable.Add (1, 2);");

                o = window.GetProperty("scriptabletest_addeventhandler_1_event_raised");
                Assert.IsInstanceOfType(o, typeof(bool), "#3 return type");
                Assert.IsFalse((bool)o, "#3 event raised");
            } catch (Exception) {
                throw;
            } finally {
                HtmlPage.UnregisterCreateableType("eventCalculator");
            }
        }
Exemplo n.º 26
0
        public void Uris_EmptyContent_ReturnsNoUris()
        {
            var page = new HtmlPage(new Uri("fake://a"), "");

            var uris = page.Uris;

            uris.Should().BeEmpty();
        }
Exemplo n.º 27
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            this.RootVisual = new MainPage();

            JsInterop so = new JsInterop();

            HtmlPage.RegisterScriptableObject("flowViewer", so);
        }
Exemplo n.º 28
0
        public ActionResult Create()
        {
            HtmlPage data       = new HtmlPage();
            var      categories = ServiceFactory.HtmlPageCategoryManager.GetAllHtmlPageCategory(Culture);

            ViewBag.Categories = new SelectList(categories, "HtmlPageCategoryId", "HlevelTitle");
            return(View("Update", data));
        }
Exemplo n.º 29
0
    public void NavigationComplete()
    {
        HtmlPage page = new HtmlPage("NavigationTimeOut.aspx");

        page.Elements.Find("btnRunTest").Click();
        Assert.IsTrue(bool.Parse(page.Elements.Find("navComplete").GetInnerText()));
        Assert.StringIsNullOrEmpty(page.Elements.Find("errorMessage").GetInnerText());
    }
Exemplo n.º 30
0
 public ViewModel()
 {
     CreateSerializer();
     HtmlPage.RegisterScriptableObject("eventViewerViewModel", this);
     Events        = new ObservableCollection <IEvent>();
     ReloadCommand = DelegateCommand.Create(Reload);
     Load();
 }
Exemplo n.º 31
0
 public void AuthInitialize()
 {
     if (oauthPublisher == null)
     {
         oauthPublisher = new OAuthDomProxy();
         HtmlPage.RegisterScriptableObject("oauthPublisher", oauthPublisher);
     }
 }
 public void Dispose()
 {
     Task.Factory.StartNew(async() =>
     {
         await HtmlPage.CloseAsync();
         await Browser.CloseAsync();
     });
 }
Exemplo n.º 33
0
 void Page_Loaded(object sender, RoutedEventArgs e)
 {
     HtmlPage.RegisterScriptableObject("Silverlight", this);
     PerformanceLogList.SelectedIndex = -1;
     //TODO: At present time the DataGrid control doesn't support adding new rows dynamically.
     //For now I'm just using a ListBox, but this is less desirable obviously.
     //SummaryGrid.ItemsSource = new ObservableCollection<PerformanceLogSummary>();
 }
Exemplo n.º 34
0
        public TimelinePage(
            )
        {
            InitializeComponent();
            HtmlPage.RegisterScriptableObject("Instance", this);

            this.KeyDown += new KeyEventHandler(OnKeyDown);
        }
Exemplo n.º 35
0
        public Page()
        {
            InitializeComponent();

            Assert.SetLog(log);

            HtmlPage.RegisterScriptableObject("Harness", this);
        }
 /// <summary>
 /// Resynchronizes calls performed from the thread where this instance has been created.
 /// </summary>
 /// <param name="page"></param>
 /// <param name="settings"></param>
 /// <param name="async"></param>
 /// <returns></returns>
 public override bool ProcessSynchron(HtmlPage page, WebRequest settings, bool async)
 {
     if (async && IsInOriginalThread())
     {
         LOG.Info("Re-synchronized call to " + settings.Url);
         return true;
     }
     return !async;
 }
Exemplo n.º 37
0
    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);
    }
Exemplo n.º 38
0
    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());
    }
Exemplo n.º 39
0
    public void HandleConfirmPopUp()
    {
        HtmlPage page = new HtmlPage("ScriptSamples.aspx");

        // click on the button and cancel the confirm
        page.Elements.Find("ButtonWithConfirm").Click(new CommandParameters(WaitFor.None,PopupAction.ConfirmCancel));
        Assert.AreEqual("", page.Elements.Find("Label1").GetInnerText());

        // click on the button and accept the confirm
        page.Elements.Find("ButtonWithConfirm").Click(new CommandParameters(WaitFor.Postback, PopupAction.ConfirmOK));
        Assert.AreEqual("The Button was clicked.", page.Elements.Find("Label1").GetInnerText());
    }
Exemplo n.º 40
0
    public void WaitUntilSpanIsUpdated()
    {
        HtmlPage page = new HtmlPage("ScriptSamples.aspx");

        // click on the button that takes 2 seconds to update a span
        page.Elements.Find("ButtonUpdatesSpan").Click();

        // wait for span
        page.Elements.Find("Span1").WaitForInnerText("Operation Complete on Span1.", 5);

        // continue with test
        Assert.AreEqual("Operation Complete on Span1.", page.Elements.Find("Span1").GetInnerText());
    }
Exemplo n.º 41
0
    private void LoginAndGoToHome(HtmlPage page)
    {
        // Navigate to Home page
        page.Navigate("Home.aspx");

        if (page.Elements.Exists(new HtmlElementFindParams("tab-login"), 0))
        {
            // If the login tab exists, then we were unauthenticated and we need to login
            page.Elements.Find("UserName").SetText("ValidUser");
            page.Elements.Find("Password").SetText("foo");
            page.Elements.Find("LoginButton").Click(WaitFor.Postback);
        }
    }
Exemplo n.º 42
0
    public void GridViewSortTest()
    {
        HtmlPage page = new HtmlPage();
        LoginAndGoToHome(page);

        // Get the gridview table
        HtmlTableElement gridView = (HtmlTableElement) page.Elements.Find("CoursesGridView");

        // Sort by name
        gridView.Rows[0].Cells[4].ChildElements[0].Click(WaitFor.AsyncPostback);

        // Verify sort operation
        Assert.AreEqual("Course Name #17", gridView.Rows[10].Cells[4].GetInnerText());
    }
Exemplo n.º 43
0
        public void AddUserHtml(string html,long UserID)
        {
            

            string html1 = "";
            string css1 = "";
            string javaScript1 = "";

            html1 = System.IO.File.ReadAllText(@"C:\Users\Darko Velickovic\Desktop\TxtHtml.txt");

            var stranica1 = new HtmlPage { id = UserID ,name = "stranica1", html = html1, css = css1, javaScript = javaScript1 };
           
            redis.StoreAsHash<HtmlPage>(stranica1);
            
        }
Exemplo n.º 44
0
    public void ErrorIfIncorrectPassword()
    {
        // Navigate to the login page
        HtmlPage page = new HtmlPage("Login.aspx");

        // Verify there is no failure text
        Assert.AreEqual("", page.Elements.Find("FailureText").GetInnerText());

        // Attempt to login with an incorrect password
        page.Elements.Find("UserName").SetText("InvalidUser");
        page.Elements.Find("Password").SetText("foo");
        page.Elements.Find("LoginButton").Click(LTAF.WaitFor.Postback);

        // Verify error message is displayed
        Assert.AreEqual("Your login attempt was not successful. Please try again.", page.Elements.Find("FailureText").GetInnerText());
    }
Exemplo n.º 45
0
    public void ToggleCreateUser()
    {
        // Navigate to the login page
        HtmlPage page = new HtmlPage("Login.aspx");

        // Verify css classes of the Login control and CreateUserWizard control divs
        Assert.AreEqual("display-block", page.Elements.Find("loginForm").GetAttributes().Class);
        Assert.AreEqual("no-display", page.Elements.Find("signupForm").GetAttributes().Class);

           // Click on the link to toggle divs
           page.Elements.Find("a", "Not a member?", 0).Click();

           // Verify css classes of the Login control and CreateUserWizard control divs
           Assert.AreEqual("no-display", page.Elements.Find("loginForm").GetAttributes().Class);
           Assert.AreEqual("display-block", page.Elements.Find("signupForm").GetAttributes().Class);
    }
Exemplo n.º 46
0
    public void GridViewPagingTest()
    {
        HtmlPage page = new HtmlPage();
        LoginAndGoToHome(page);

        // Get the gridview table
        HtmlTableElement gridView = (HtmlTableElement)page.Elements.Find("CoursesGridView");

        // Verify current last entry
        Assert.AreEqual("Course Name #9", gridView.Rows[10].Cells[4].GetInnerText());

        // Go to page two
        gridView.Rows[11].ChildElements.Find("a", 0).Click(WaitFor.AsyncPostback);

        // Verify current last entry
        Assert.AreEqual("Course Name #19", gridView.Rows[10].Cells[4].GetInnerText());
    }
Exemplo n.º 47
0
    public void SignInAndSignOut()
    {
        // Navigate to the login page
        HtmlPage page = new HtmlPage("Login.aspx");

        // Fill Login control user/password and click login button
        page.Elements.Find("UserName").SetText("ValidUser");
        page.Elements.Find("Password").SetText("foo");
        page.Elements.Find("LoginButton").Click(WaitFor.Postback);

        // Verify content of the Home page
        Assert.AreEqual("Welcome back ValidUser!", page.Elements.Find("LoginName1").GetInnerText());

        // Click the logout tab
        page.Elements.Find("tab-signout").Click(WaitFor.Postback);

        // Verify login tab now exists.
        Assert.IsTrue(page.Elements.Exists("tab-login"));
    }
Exemplo n.º 48
0
        public  bool testing(int howMany)
        {
            string testHtml = " <div>\n\t <h1>Testing purpose</h1> \n </div>";

            for (int i = 0; i < howMany; i++)
            {
                var page = new HtmlPage 
                {
                    id = i,
                    name = "pageNumber"+(i+1).ToString(),
                    html = testHtml,
                    css = "",
                    javaScript = ""
                };
                redis.StoreAsHash<HtmlPage>(page);
            }

                return true;
        }
Exemplo n.º 49
0
        public void AddUserHtml(string html,long UserID)
        {
            string html1 = "";
            string css1 = "";
            string javaScript1 = "";

            html1 = System.IO.File.ReadAllText(@"C:\Users\Darko Velickovic\Desktop\TxtHtml.txt");

            // --- Za preciscavanje texta ---
            html1 = Regex.Replace(html1, @"\t|\r", " ");
            html1 = Regex.Replace(html1, @"( \n){2,}", "\n");
            html1 = Regex.Replace(html1, " {2,}", " ");

            var stranica1 = new HtmlPage { id = UserID ,name = "stranica1", html = html1, css = css1, javaScript = javaScript1 };

            redis.StoreAsHash<HtmlPage>(stranica1);
        }
Exemplo n.º 50
0
 private static IEnumerable<HtmlElement> FindAllElementsByTagName(HtmlPage page, string tagName)
 {
     // Ideally we'd use page.Elements.FindAll(tagName), but this seems not to work
     int index = 0;
     HtmlElement element = page.Elements.Find(tagName, index);
     while(element != null) {
         yield return element;
         index++;
         element = page.Elements.Find(tagName, index);
     }
 }
Exemplo n.º 51
0
 private static HtmlElement GetElementByAttributeValue(HtmlPage page, string tagName, string attributeName, string attributeValue)
 {
     var matchingElements = from elem in FindAllElementsByTagName(page, tagName)
                            let attribs = elem.GetAttributes()
                            where attribs.Get(attributeName, (string) null) == attributeValue
                            select elem;
     return matchingElements.FirstOrDefault();
 }
Exemplo n.º 52
0
    private static void TestFieldValidation(string inputField, string invalidValue, string validValue, string expectedFailureMessage, Action<HtmlPage> additionalSetup)
    {
        var page = new HtmlPage();
        page.Navigate(TestPageUrl);

        if (additionalSetup != null)
            additionalSetup(page);

        // Put in invalid value
        var inputControl = page.Elements.Find(inputField);
        inputControl.SetText(invalidValue, true);
        page.Elements.Find("submitButton").Click();

        // Check error message has appeared
        var errorMessage = GetElementByAttributeValue(page, "span", "htmlfor", inputControl.Id);
        Assert.IsNotNull(errorMessage);
        Assert.AreEqual("span", errorMessage.TagName);
        Assert.AreEqual(inputControl.Id, errorMessage.GetAttributes()["htmlfor"]);
        Assert.IsTrue(errorMessage.IsVisible());
        Assert.AreEqual(expectedFailureMessage, errorMessage.GetInnerHtml());

        // Now put in a valid value
        inputControl.SetText(validValue);
        inputControl.DispatchEvent(HtmlEventName.KeyUp);

        // Check error message is gone
        Assert.IsFalse(errorMessage.IsVisible());
    }
Exemplo n.º 53
0
 /// <summary>
 /// Gets notified of an AJAX call to determine how it should be processed.
 /// </summary>
 /// <param name="page">the page the request comes from</param>
 /// <param name="request">the request that should be performed</param>
 /// <param name="async">indicates if the request should originally be asynchronous</param>
 /// <returns>if the call should be synchronous or not; here just like the original call</returns>
 public bool ProcessSynchron(HtmlPage page, WebRequest request, bool async)
 {
     return !async;
 }
Exemplo n.º 54
0
    public void ValidatorsShownIfTextBoxesNotFilled()
    {
        // Navigate to the login page
        HtmlPage page = new HtmlPage("Login.aspx");

        // Verify validators are not visible
        Assert.IsFalse(page.Elements.Find("UserNameRequired").IsVisible());
        Assert.IsFalse(page.Elements.Find("PasswordRequired").IsVisible());

        // Click the login button (do not wait for postback)
        page.Elements.Find("LoginButton").Click();

        // Verify validators are now visible
        Assert.IsTrue(page.Elements.Find("UserNameRequired").IsVisible());
        Assert.IsTrue(page.Elements.Find("PasswordRequired").IsVisible());
    }
Exemplo n.º 55
0
 public void VerifyTheAspNetErrorPage()
 {
     HtmlPage p = new HtmlPage("PageWithError.aspx");
     bool pageFail = p.IsServerError();
     Assert.IsTrue(pageFail);
 }