javascriptsahi

Sahi Pro - not able to get the value from the web page


I am trying to get dynamic text from the web page using the sahi pro script. I used following script to get the text.

_setValue(_textbox("j_username"), "******");
_setValue(_password("j_password"), "*****");
_click(_span("Login"));
_click(_span("Home"));

var $date = _getText(_div("/bwc-selected/"));
var $number = parseInt(_extract($date, "/(.*)bwc-selected/", true));

The html code display as below:

<div class="date-display 20170301 bwc-selected">Wednesday 01 Mar 2017</div>

Here, in the above html code I need to get the dynamic date "20170301" or "Wednesday 01 Mar 2017"

no luck till now.


Solution

  • I updated my code as below and I am able to extract the date:

    _setValue(_textbox("j_username"), "*****");
    _setValue(_password("j_password"), "*****");
    _click(_span("Login"));
    _click(_span("Home"));
    
    _wait(2000);
    
    var $date = _getText(_div("/date-display .* bwc-selected/"));
    
    _wait(2000);
    
    _log($date);