Esempio n. 1
0
 public static WatiN_IE jQuery_Append_Body(this WatiN_IE ie, string htmlToAppend)
 {
     ie.eval("$('body').append('<div>{0}<div>')".format(htmlToAppend));
     return(ie);
 }
Esempio n. 2
0
        public void Workflow_Install_And_Delete_Library()
        {
            Action <string, string> waitForElementText =
                (elementId, text) => {
                "waiting for '{0}' in element '{1}'".info(text, elementId);
                for (int i = 0; i < 5; i++)
                {
                    if (ie.element(elementId).text().contains(text))
                    {
                        return;
                    }
                    else
                    {
                        elementId.sleep(1000, true);
                    }
                }
                "could not find '{0}' in element '{1}'".error(text, elementId);
            };

            Action <string, string> login =
                (username, password) => {
                ie.open(server.append("login"));
                ie.url().assert_Contains("Login");
                ie.field("username").value(username);
                ie.field("password").value(password);
                ie.button("login").click();
            };
            Action logout     = () => ie.open(server.append("logout"));
            Action teamMentor = () => {
                ie.open(server.append("teamMentor"));
                ie.waitForLink("About");
            };
            Action admin = () => ie.open(server.append("admin"));

            Action login_AsAdmin = () => {
                if (ie.hasLink("Control Panel").isFalse())
                {
                    logout();
                    login(admin_Name, admin_Pwd);
                    ie.waitForLink("About", 250, 20).assert_Not_Null();
                    ie.waitForLink("Logout").assert_Not_Null();
                    //teamMentor();
                }
            };
            Action installTestLibrary =
                () => {
                admin();
                ie.waitForComplete();
                ie.waitForLink("advanced admin tools").click().assert_Not_Null();
                ie.waitForLink("install/upload libraries").click().assert_Not_Null();;
                ie.waitForLink("OWASP").click().assert_Not_Null();
                ie.button("Install").click().assert_Not_Null();
                waitForElementText("installMessage", "> Library installed was successful");
                ie.link("Admin Tasks").click().assert_Not_Null();
                waitForElementText("jsonResult", "...Via Proxy");
                ie.link("Reload Server Cache").click().assert_Not_Null();
                waitForElementText("jsonResult", "In the Folder");
                ie.link("Open Main Page").click().assert_Not_Null();;
                //ie.waitForLink("Reload Server Cache").click();
            };
            Action deleteTestLibrary =
                () => {
                ie.waitForLink("OWASP").notNull().assert_True();

                var librariesBeforeRemove = ie.getJsVariable("window.TM.WebServices.Data.AllLibraries.length").cast <int>();

                ie.eval("window.TM.Gui.LibraryTree.remove_Library_from_Database('4738d445-bc9b-456c-8b35-a35057596c16')");

                for (var i = 0; i < 5; i++)
                {
                    if (ie.getJsVariable("window.TM.WebServices.Data.AllLibraries.length").cast <int>() < librariesBeforeRemove)
                    {
                        return;
                    }
                    else
                    {
                        100.sleep();
                    }
                }

                "Library was not deleted".assert_Fail();
            };

            teamMentor();
            login_AsAdmin();
            //ie.script_IE_WaitForClose();
            installTestLibrary();
            deleteTestLibrary();

            ie.hasLink("OWASP").assert_False();
        }