コード例 #1
0
        public void add_javascript()
        {
            var script = String.Format("{0}alert('hello');{0}alert('world');{0}", Environment.NewLine);

            document.AddJavaScript(script);

            var expected = String.Format(
                "</title><script type=\"text/javascript\">{0}{0}alert('hello');{0}alert('world');{0}{0}</script></head>",
                Environment.NewLine);

            document.ToString().ShouldContain(expected);
        }
コード例 #2
0
        private void addTest(Test test, HtmlDocument document)
        {
            string json   = new TestWriter().WriteToJson(test);
            string script = "var test = new Step({0});".ToFormat(json);

            document.AddJavaScript(script);
        }
コード例 #3
0
        private void addJavascriptFiles(HtmlDocument document)
        {
            var scripts = new string[] { JQUERY, STORYTELLER };

            Embeds.WriteFiles();
            var files = Embeds.GetFiles();

            scripts.Each(s =>
            {
                var file = files.First(x => x.FileName == s);
                document.AddJavaScript(file.Contents());
                //document.ReferenceJavaScriptFile(file.FullPath);
            });



            files.Where(x => !scripts.Contains(x.FileName)).Each(file =>
            {
                document.AddJavaScript(file.Contents());
                //document.ReferenceJavaScriptFile(file.FullPath);
            });
        }
コード例 #4
0
        public void Start(string description, DateTime runningTime)
        {
            _document = new HtmlDocument();
            _document.AddStyle(HtmlClasses.CSS());
            _document.Add("h1").Text(description);

            _document.AddJavaScript(HtmlClasses.JQuery());
            _document.AddJavaScript(HtmlClasses.SummaryFilter());
            _document.Add("div").Text("Executed at {0}".ToFormat(runningTime)).AddClass(HtmlClasses.CAPTION);

            _document.Add("hr");

            // _document and _table are HtmlTag objects
            _table = _document.Add("table");
            _table.Add("thead/tr", x =>
            {
                x.Add("th").Text("Test");
                x.Add("th").Text("Lifecycle");
                x.Add("th").Text("Result");
            });

            _tbody = _table.Add("tbody");
        }
コード例 #5
0
        protected override void ConfigureDocument(HtmlDocument document)
        {
            var textbox = new TextboxTag(EmptyTextboxName, string.Empty)
                          .Id(EmptyTextboxId)
                          .Data("value", "some value");

            document.Add(textbox);

            var button = new HtmlTag("button")
                         .Id(DelayAddElementButtonId)
                         .Text("Append element");

            document.Add(button);

            var appendedElementsDiv = new DivTag().AddClass(AddedElementsClass);

            document.Add(appendedElementsDiv);

            document.ReferenceJavaScriptFile("file:///" + "jquery-2.0.3.min.js".ToFullPath());

            document.AddJavaScript("$(function() { $('#" + DelayAddElementButtonId + "').click(function() { setTimeout(function() { $('." + AddedElementsClass + "').append('<p>blah</p>'); }, 3000); }); });");
        }