18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to capture data from a browser and export to excel

MuruganMurugan Members
edited November -1 in Sahi - Open Source
OS Name - Windows 7
Browser Name and version - IE 8.0
Sahi Build (Available on Sahi controller's Info tab)- (Build: 2011-05-25)

I want to capture the below information displayed in the application export the information to excel

Dropdown 'City' - this will list Chennai, Mumbai, Delhi etc..

Current Count - 100
Assigned Count - 50
Unassigned Count - 50

The counts will be displayed as a display only text field in the application.

Is it possible to automate to capture the counts for the cities one by one and export the same to the excel

Thanks,
Vatsan

Comments

  • Hi,

    I'm also looking a solution exactly similar to the scenario mentioned by Murugan.

    In my application there is one dropdown called Showroom where many showrooms will be listed ( e.g . Chennai, Delhi, Bangalore etc)

    User can select the Showroom be selecting the value from the dropdown , then the following will be listed in the page as per the showoom value selected.

    Total No.of. Customers : 100
    No.of. Members : 50
    No. of. Leads: 50

    Can we automate the above scenario by writing a function to capture the counts displayed in a page and export the same to excel sheet

    Please help

    Thanks
  • sivasiva Members
    Hi,

    yes we can automate the scenario

    if you can send me the link where that drop down options exist i can provide a code for you folks


    Regards,
    Siva
  • Hi,

    Im not able to view the posts replied by Sumitra ...i was able to see that post couple of mins back..

    can you please post that again.


    Thanks
  • Hi Vatsan,

    You can try with the following code:
    //input is an array of cities
    Var $cityName = [Delhi,chennai,Bangalore];
    
    //it is expected 2d array of retrieved data 
    var $dataToWrite = new Array();
    
    for(var $i=0;$i<$cityName.length;$i++){
        $dataToWrite[i] = new Array();
        getDetails($cityName[i], $dataToWrite[i]);
    }
    
    function getDetails($cityName, $data){
        _setSelected(_select("ctl00\$MainContent\$ddlShowRoom"), $cityName);
        $data[0] = _getText(_span("MainContent_lblCurrentLeadCount"));
        $data[1] = _getText(_span("MainContent_lblAssigned"));
        $data[2] = _getText(_span("MainContent_lblUnassigned"));
    }
     
    _writeCSVFile($data, "<path-of-csv-file>");
    

    Let me know if this solves your issue.

    Regards
    Sumitra
  • Sumitra,

    Thanks for replying. The CSV file is not getting created using the script below. please refer the same and let me know your thoughts.

    function selectshowroom($sr){
    _click(_select(0));
    _setSelected(_select(0),$sr);
    //_setSelected(_select("ctl00\$MainContent\$ddlShowRoom"), $sr);

    }

    var $values = ["Akron", "Albany", "Chicago"];
    var $dataToWrite = new Array();
    var $data1;
  • for (var $i=0; $values!="undefined" && $i<$values.length ; $i++)
    {
    selectshowroom($values $i);
    _alert(_getText(_span("MainContent_lblCurrentLeadCount")));
    $dataToWrite i = new Array();
    getDetails($values i, $dataToWrite i);
    }

    function getDetails($cityName, $data)
    {

    _alert("before _SetSelected");
    _setSelected(_select("ctl00\$MainContent\$ddlShowRoom"), $cityName);

    _alert("before Data asign");
    $data[0] = _getText(_span("MainContent_lblCurrentLeadCount"));
    $data[1] = _getText(_span("MainContent_lblAssigned"));
    $data[2] = _getText(_span("MainContent_lblUnassigned"));
    _alert("After Data asign");
    _alert($data[0] + $data[1] + $data[2] );

    $data1 = $data[0] + "," + $data[1] + "," + $data[2];


    }

    _alert("before csv write");
    _alert($dataToWrite[0] + " \n" + $dataToWrite[1] + "\n" +$dataToWrite[2]);
    _alert($data1);

    var $data = [ [2, 3, 5], [1, 2, 4], [4, 3, 7] ];

    _writeCSVFile($data , "D:\Test\ex.csv", true, ",");



    _alert("After csv write");
  • Once again thank you sumitra. i have automated the above scenario and works fine.

    Will keep posting.
This discussion has been closed.