18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Problem with _set()
Hi,
Here is my code snippet:
Anybody having a solution or any idea plz help me.
Thanks and Regards,
Pankaj.
Here is my code snippet:
var $quest1 = /\[\d*\] Text Statement/;
var $y1;
_set($y1, _spandiv($quest1).innerHTML);
var $val = $y1.substring(1, 5);
_alert($val);
Now my problem is that although the value of $y1 is getting set properly and alert shows the proper value that i need. But the results show script failed with error as: "TypeError: $y1 has no properties".Anybody having a solution or any idea plz help me.
Thanks and Regards,
Pankaj.
Comments
Only thing I could figure out is that its appearing due to the jscript function substring() that i m using.
Any other way to get a substring from the text? I need to get the numeric part from the text. I hope regular expression can help. Please suggest.
Regards,
Pankaj.
will b back if I get stuck again..:)
Thanks.
Pankaj.
Sure i will. Thats the purpose of this community after all..:)
I tried this: I needed the four digit number here.
Instead of assigning the required value to a variable later on, its always better to assign it directly in the _set() statement itself.
Regards,
Pankaj.
Because I've got a big problem (similar as yours) with _set() function...
If I use it, I have an "element has no properties" failure ...!
The code is in my "Selected Boxes" topic just in case
I swear to God this worked yesterday:
_set($current_budget, _textbox("campaignbudget").value);
Today I'm seeing this error:
handleSet('\$current_budget' + 10, _textbox("campaignbudget").value);
Try using the last loop in your code in a function as you did for the other part. The issue is same: page dependent variables used in for loop.
function abc(){
for( var $i=0; $i < $countries_gsm_d.length; $i++){
$arr[$i] = _select("dev_country").options[$i].text;
}
}
Regards,
Pankaj.
Please write your code snippet if possible. we can have a better understanding then and think it over
Regards,
Pankaj.
I don't understand chat you said because my code works fine..!
function abc($countries_gsm_d, $arr){
for( var $i=0; $i < $countries_gsm_d.length; $i++){
$arr[$i] = _select("dev_country").options[$i].text;
}
}
is not a problem ...
But it's not useful because after the first function, I already have an array that contains the list of my options (countries) ... so it's useless!
The _set I'm having trouble with is at the top of the script. If I copy that portion and run it as a separate script, it works fine.
If I incorporate it into a longer script of 150 lines or so, it fails.
It's seems like the variable is undefined...
... and I just looked at the log and there is much more information in there:
I'm going to do some more investigating.
Got any further?
I was mixing variables with "$" and no $.
This code after parsing, will become: So the sequence of execution has become: So the substring fails, since $y1 has not been initialized!
The correct way would be: or I would recommend the former solution.
This piece of information really describes many things.:)
Thanks
Pankaj.
http://www.w3schools.com/htmldom/dom_using.asp