Calling .cgi file from script and read dynamically generated values
Hi,
I am doing desktop testing where I need to call .cgi script that will dynamically generate caserun IDS for testcases. I am able to call .cgi script as below.
var WScriptObj = Sys.OleObject("WScript.Shell");
for example: path = "http://ip address/tr_new_run_testcomplete.cgi?&environment=Lab&cases=4,5,6,7"
WScriptObj["Run"]("path");
CaseRun ID created as below.
{success: true, run_id: 35}
Test Case 25: CaseRun ID: 113
I need to get that value of CaseRunID. Need to figure out,
1) How can I save that page?
2) Can I open it with notepad and read content as string.
After that I need to call other .cgi file to update status of each test case based on CaseRun ID.
Thanks,
OK so if you want to go with the "paste URL into browser" approach, you need to launch the browser and get the web page contents as follows.
If you have the Web testing module:
// Open the page in a browser (replace btIExplorer with your default browser)
Browsers.Items(btIExplorer).Run(CreateCaseRunID_Path); var page = Sys.Browser().Page(CreateCaseRunID_Path);
// Get the page's source code var str = page.contentDocument.documentElement.outerHTML; // TODO: extract values from strIf you don't have the Web testing module, and assuming your default browser is IE:
// Open the page in IE
var ie = Sys.OleObject("InternetExplorer.Application");
ie.Visible = true; ie.Navigate(CreateCaseRunID_Path); while (ie.ReadyState != 4) Delay(100);
// Get the page's source code var str = ie.Document.documentElement.outerHTML; // TODO: extract values from strLet us know if this works for you.
>>
if I copy paste url string it loads the page fine without asking login info.
<<
It could be that you're already logged into this system in your browser - that's why it doesn't prompt for login. For example, you logged in a few weeks ago, or it uses your Windows account, or something like that. I initially suggested the approach with programmatic login so that the script is portable and doesn't depend on your current computer state (such as the browser you use). But of course you are free to use whatever method suits you best and works best for you. :)