Forum Discussion

sshah1's avatar
sshah1
Contributor
10 years ago

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("...
  • HKosova's avatar
    HKosova
    10 years ago

    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 str

     

    If 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 str

     

    Let 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. :)