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.

_writeToFile with data from the html page

jivernawjivernaw Members
edited November -1 in Sahi - Open Source
Hello, I would like to write some data as a result of testing from generated html into the file. Whenever I use a variable with _writeToFile function it fails. What am I doing wrong? Are there any other methods to do the same job? Thanks.


function writeToFile($message, $myPath){
var out = new java.io.FileWriter($myPath, true);
out.write($message + "\n");
out.close();
}

var $aa="";

$aa= _getText(_cell("/8000/"));

_writeToFile($aa, "C:\\test_esecution.log"); // Fails
_writeToFile("Test", "C:\\test_esecution.log"); // Works

Comments

  • narayannarayan Administrators
    You need to get the value like this:

    var $aa = "";
    _set($aa, _getText(_cell("/8000/")));
    _writeToFile($aa, "C:\\test_esecution.log");
  • That worked in evaluation expression on a controller stoped, but not in replay, thanks.
    After the login our application opens another window fullscreen without bars etc, and the explorer
    fires the security message whenever i'm sure to close a parent window, so it runs in popup.

    I don't know how to simulate the same conditions, but with that window opened all the scripts run smoothly, except when i'm trying to get something from html.


    _popup("dialogo")._setValue(_textbox("contentSubView:formSearch:personSurnameInput"), "SURNAME");
    var $message="";
    _set($message, _popup("dialogo")._getText(_textbox("contentSubView:formSearch:personSurnameInput")));
    _debugToFile($message, “C:\sahi_debug.log”);


    Error in script: setServerVar('\$message', _popup("dialogo")._getText(_textbox("contentSubView:formSearch:personSurnameInput")));
    Window not found: popupNameFromStep=; derivedName=dialogo; windowName=dialogo; windowTitle=Ricerca Contatto; wasOpened=1;
  • narayannarayan Administrators
    For popups, _set works like this:

    _popup("dialogo")._set($message, _getText(_textbox("contentSubView:formSearch:personSurnameInput")));
  • It worked as it said! Thanks a lot!
This discussion has been closed.