Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

different results with a script run and "Evaluate expression" execution

TSissonCredTSissonCred Members
edited November 2013 in Sahi Pro
Sahi Pro 5.0.9

I'm running the following code inside a function and also within the Controller > Record tab > Evaluate Expression and I'm getting very different results but I can't figure out why.

The code is extracting the client_id from the href attribute of the Profile link:
var $id;
$id = _link("Profile").getAttribute("href");  
_alert($id);
$id = $id.match(/client_id=\d*/).toString();
_alert($id);
$id = $id.substr(10);
_alert($id);

When I run it through the Controller > Record tab > Evaluate Expression field I get the following values for the 3 alerts:
1: /client/client_view.asp?frommycwclient=1&client_id=11345
2: client_id=11345
3: 11345

However, when I the same code either in a script using testrunner or through the Controller > Playback (debug), I get the following values for the alerts:
1. /client/client_view.asp?frommycwclient=1&client_id=11345
2. _sahi._link("Profile").getAttribute("href").match(/client_id=\d*/)
3. k("Profile").getAttribute("href").match(/client_id=\d*/)

As you can see, the call to get the href attribute works fine as both of the initial _alert outputs match. The string matching is where it appears to break. It appears as though it's somehow concatenating the two calls (lines 2 & 4 in the code) as you can see from the 2nd _alert output.

Best Answer

Answers

Sign In or Register to comment.