Last active
August 29, 2015 14:03
-
-
Save DinisCruz/a57be701a893606d5928 to your computer and use it in GitHub Desktop.
QA IE Automation script to import and delete accounts in TM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var admin_Name = "admin"; | |
var admin_Pwd = "********"; | |
var server = "http://127.0.0.1:32768/"; | |
//helper method (should be an extension method) | |
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); | |
}; | |
// TM action automation | |
Action<string,string> login = (username,password)=> | |
{ | |
ie.open(server.append("login")); | |
ie.field("username").value(username); | |
ie.field("password").value(password); | |
ie.button("login").click(); | |
}; | |
Action teamMentor = ()=> | |
{ | |
ie.open(server.append("teamMentor")); | |
ie.waitForLink("About"); | |
}; | |
Action login_AsAdmin = ()=> | |
{ | |
if (ie.hasLink("Control Panel").isFalse()) | |
{ | |
logout(); | |
login(admin_Name, admin_Pwd); | |
teamMentor(); | |
} | |
}; | |
Action logout = ()=> ie.open(server.append("logout")); | |
Action tbot = ()=> ie.open(server.append("tbot")); | |
Action admin = ()=> ie.open(server.append("admin")); | |
// TM workflows | |
Action installTestLibrary = ()=> | |
{ | |
admin(); | |
ie.waitForComplete(); | |
ie.waitForLink("advanced admin tools").click();; | |
ie.waitForLink("install/upload libraries").click(); | |
ie.waitForLink("OWASP").click(); | |
ie.button("Install").click(); | |
waitForElementText("installMessage","> Library installed was successful"); | |
ie.link("Admin Tasks").click(); | |
waitForElementText("jsonResult", "...Via Proxy"); | |
ie.link("Reload Server Cache").click();; | |
waitForElementText("jsonResult", "In the Folder"); | |
ie.link("Open Main Page").click(); | |
}; | |
Action deleteTestLibrary = ()=> | |
{ | |
if (ie.waitForLink("OWASP").notNull()) | |
ie.eval("window.TM.Gui.LibraryTree.remove_Library_from_Database('4738d445-bc9b-456c-8b35-a35057596c16')"); | |
5.loop((i)=>{ | |
100.sleep(); | |
return (ie.getJsVariable("window.TM.WebServices.Data.AllLibraries.length").cast<int>()) > 0; | |
}); | |
}; | |
// entire workflow | |
teamMentor(); | |
login_AsAdmin(); | |
installTestLibrary(); | |
deleteTestLibrary(); | |
return ie.hasLink("OWASP"); | |
//ie.inject_FirebugLite(); | |
//O2Ref:FluentSharp.WatiN.dll | |
//using FluentSharp.Watin | |
//using WatiN.Core | |
//O2Ref:WatiN.Core.dll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment