-1

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.

Curious
  • 282
  • 4
  • 21

2 Answers2

0

You get the "Wednesday 01 Mar 2017" part with _getText(_div("/bwc-selected/")); just fine. For the "20170301" part, use _div("/bwc-selected/").className

globalworming
  • 757
  • 1
  • 5
  • 33
  • hi - Actuallly, I missed one more element for locating the date. I updated code as var $date = _getText(_div("/date-display .* bwc-selected/")); _wait(2000); _log($date); and it worked for me. – Curious Mar 02 '17 at 16:57
0

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);
Curious
  • 282
  • 4
  • 21