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.
TypeError: Object required when trying to set variable
I have a script where I set the value of a textbox, then try to retrieve the value and assign it to a variable. When I try to run the script from the Sahi controller's playback tab, I get the following error:
Error loading script. Firefox may point to the exact line. TypeError: Object required
No trace available
Here is a snippet...
Anyone have any ideas?
Thanks in advance...
Error loading script. Firefox may point to the exact line. TypeError: Object required
No trace available
Here is a snippet...
for (var i = 0; i < 17; i++) {
_keyPress(document.getElementById('LoginControlMain1_txtUserID'), 'x');
_keyPress(document.getElementById('LoginControlMain1_txtUserID'), 'y');
_keyPress(document.getElementById('LoginControlMain1_txtUserID'), 'z');
_log("in loop: " + document.getElementById('LoginControlMain1_txtUserID').value, "custom4");
}
_assertNotNull(document.getElementById('LoginControlMain1_txtUserID')); // Returns true
_assertNotNull(document.getElementById('LoginControlMain1_txtUserID').value); // Returns true
var $uid015 = document.getElementById('LoginControlMain1_txtUserID').value; // Script fails at this line if active
What's odd is that this code runs perfectly fine on the record tab, using the Test --> button. Also, the rest of the script will run fine on the playback tab if I comment out the variable assignment. I placed the assertions in to verify that the object was there, and they return true. Also, the _log() statement within the loop references the same object, and works properly...so I'm a bit baffled. I've tried a ton of different methods of getting the value. I've even tried using _call() and _eval() - all with the same result.Anyone have any ideas?
Thanks in advance...
Comments
http://sahi.co.in/w/_byid
is incorrect because it sets a page dependent variable directly.
Use or better still: