当前位置: 首页>>代码示例>>C#>>正文


C# IWebDriver.MonitorJQueryAjax方法代码示例

本文整理汇总了C#中IWebDriver.MonitorJQueryAjax方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.MonitorJQueryAjax方法的具体用法?C# IWebDriver.MonitorJQueryAjax怎么用?C# IWebDriver.MonitorJQueryAjax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWebDriver的用法示例。


在下文中一共展示了IWebDriver.MonitorJQueryAjax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SpecifyForBrowser

        public override void SpecifyForBrowser(IWebDriver browser)
        {
            var waitHandle = beforeAll(() => new ManualResetEvent(false));

            beforeEach(() => waitHandle.Reset());

            var server = beforeAll(() => new NancyModuleRunner(c => c.Dependency(waitHandle).Module<SomeTestServer>()));

            it("requires jQuery", delegate
            {
                browser.Navigate().GoToUrl(server.UrlFor("homepage.html"));

                Assert.Throws<JQueryNotInstalledException>(delegate
                {
                    browser.MonitorJQueryAjax();
                });

                Assert.Throws<JQueryNotInstalledException>(delegate
                {
                    browser.IsAjaxPending();
                });
            });

            describe("MonitorJQueryAjax", delegate
            {
                it("must be called before waiting on ajax", delegate
                {
                    browser.Navigate().GoToUrl(server.UrlFor("pageWithJQuery.html"));

                    var exceptions = Assert.Throws<InvalidOperationException>(delegate
                    {
                        expect(() => !browser.IsAjaxPending());
                    });

                    expect(() => exceptions.Message.Contains("Must call MonitorJQueryAjax before waiting on ajax."));
                });

                it("installs some javascript code for monitoring", delegate
                {
                    browser.Navigate().GoToUrl(server.UrlFor("pageWithJQuery.html"));

                    expect(() => !JQueryAjaxWaiter.WasMonitoringStarted(browser));

                    browser.MonitorJQueryAjax();

                    expect(() => JQueryAjaxWaiter.WasMonitoringStarted(browser));
                });

                it("doesnt reinstall that javascript code", delegate
                {
                    browser.Navigate().GoToUrl(server.UrlFor("pageWithJQuery.html"));

                    browser.MonitorJQueryAjax();

                    var scriptExecutor = browser as IJavaScriptExecutor;
                    scriptExecutor.ExecuteScript("window.SizSelCsZzz_IsRequestPending.tracer = true;");

                    browser.MonitorJQueryAjax();

                    expect(() => (bool)scriptExecutor.ExecuteScript("return window.SizSelCsZzz_IsRequestPending.tracer;"));
                });
            });

            describe("IsRequestPending indicates if an AJAX request is pending", delegate
            {
                it("returns false initially", delegate
                {
                    browser.Navigate().GoToUrl(server.UrlFor("pageWithJQuery.html"));

                    browser.MonitorJQueryAjax();

                    expect(() => !browser.IsAjaxPending());
                });

                when("the browser starts a long-running ajax operation", delegate
                {
                    arrange(delegate
                    {
                        browser.Navigate().GoToUrl(server.UrlFor("pageWithJQuery.html"));

                        browser.MonitorJQueryAjax();

                        var executor = browser as IJavaScriptExecutor;
                        executor.ExecuteScript("jQuery.ajax(" + Newtonsoft.Json.JsonConvert.SerializeObject(server.UrlFor("wait")) + ");");
                    });

                    ignoreIfInternetExplorer("not sure why this test isn't working on IE- may be a test only bug");

                    then("IsAjaxPending returns true", delegate
                    {
                        expect(() => browser.IsAjaxPending());
                    });

                    when("that longrunning call completes", delegate
                    {
                        beforeEach(() => waitHandle.Set());

                        then("IsAjaxPending returns false", delegate
                        {
                            expectEventually(() => !browser.IsAjaxPending());
//.........这里部分代码省略.........
开发者ID:fschwiet,项目名称:SizSelCsZzz,代码行数:101,代码来源:JQueryAjaxWaiter_waits_for_ajax_requests.cs


注:本文中的IWebDriver.MonitorJQueryAjax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。