public void TestJQueryInstallScript_doesNotReloadJQuery(string browserType)
        {
            UseBrowser(browserType);

            ScriptLoader loader = new ScriptLoader();

            GoToResource("cheeseburger.htm");

            Browser.Link(Find.ByClass("cheeseburger")).WaitUntilExists();
            Browser.RunScript("window.$.isThisTheOriginal$=true;");

            var marker2 = Browser.Eval("window.$.isThisTheOriginal$");
            Assert.AreEqual("true", marker2);
            
            //  The value $.isThisTheOriginal$ is set to true, so we can detect if $ is overwritten

            string js = loader.GetJQueryInstallScript();
            Browser.RunScript(js);
            try
            {
                Browser.WaitUntilContainsText("textnotfound", 5);
            }
            catch (Exception)
            {
            }

            Assert.AreEqual("true", Browser.Eval("window.$.isThisTheOriginal$"));
        }
        public void TestCanLoadJqueryInstallScript()
        {
            var sut = new ScriptLoader();

            string result = sut.GetJQueryInstallScript();

            Assert.IsTrue(result.Length > 100);
        }
        public void matches_only_class(string browserType)
        {
            UseBrowser(browserType);

            ScriptLoader loader = new ScriptLoader();

            GoToResource("MarkerConstraintTest.htm");

            Browser.Element(Find.ById("fourth").And(new MarkerConstraint("marker"))).WaitUntilExists(5);
        }
        public void TestGetCssMarkRemovalScript()
        {
            string cssSelector = Some.String();
            string markerClass = Some.String();

            var sut = new ScriptLoader();

            var result = sut.GetCssMarkRemovalScript(cssSelector, markerClass);

            Assert.IsTrue(result.Length > 10);
        }
        public void doesnt_match_other(string browserType)
        {
            UseBrowser(browserType);

            ScriptLoader loader = new ScriptLoader();

            GoToResource("MarkerConstraintTest.htm");

            Thread.Sleep(TimeSpan.FromSeconds(5).Milliseconds);

            Browser.Element(Find.ById("fifth").And( new MarkerConstraint("marker").Not())).WaitUntilExists(5);
        }
        public void TestJQueryInstallScript_loadsJQueryIfNotLoaded(string browserType)
        {
            UseBrowser(browserType);

            ScriptLoader loader = new ScriptLoader();

            GoToResource("burger.htm");

            Assert.AreEqual("undefined", Browser.Eval("typeof window.jQuery"));

            string js = loader.GetJQueryInstallScript();
            Browser.RunScript(js);

            Browser.Element(e => e.TagName.ToLower() == "script" && e.GetAttributeValue("src") == "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js").WaitUntilExists();

            var content = Browser.Eval("window.jQuery('a.plainburger').length");

            Assert.AreEqual("1", content);
            Assert.IsTrue(Browser.Eval("window.jQuery").StartsWith("function"));
        }
        public void TestGetCssMarkingScript_marksElements(string browserType)
        {
            UseBrowser(browserType);

            ScriptLoader loader = new ScriptLoader();

            GoToResource("veggieburger.htm");

            Browser.Link(Find.ByClass("veggieburger")).WaitUntilExists();

            Assert.AreEqual("0", Browser.Eval("window.jQuery('.marker').length"));

            var script = loader.GetCssMarkingScript("a.veggieburger", "marker");
            Browser.RunScript(script);

            Assert.AreEqual("1", Browser.Eval("window.jQuery('.marker').length"));
        }