Forum Discussion
8 Replies
Sort By
- jose_pitaSuper ContributorI don't think that's possible...
Can't you make a loop looking for the object and only continue when you find it?
while(!object.Exists)
{
look for object
} - karkadilValued ContributorI agree, this is not possible, but this is a good feature to have.
Tanya, could you please register this request with 2 votes?
The idea is to be able to run inside the Event Handler the statement which fired the event (smth. like reraise statement). - Ryan_MoranValued ContributorThis is actually possible to do...
JScript example:
function main(){
Log.Error('I won\'t log anything I promise :)!');
}
function dosomething(g){
wshell = new ActiveXObject('WScript.Shell');
wshell.popup(g.str);
/* of course you would need to have handling to call back the function being
performed but hopefully you get the point from this basic example */
}
function onlogerror(s,g){
g.Locked = true;
dosomething(g);
} - karkadilValued ContributorRyan, the idea is to automatically rerun the statement which caused the error, not to call a function.
- Ryan_MoranValued ContributorYes I understand that. So you add your own handling. Which you would have to do regardless to avoid endless loops and such.
function main(){
try{
Log.Error('hi i am an expected error');
}
catch(e){
Log.Error('hi i am an error that was unexpected');
}
}
function onlogerror(s,g){
g.Locked = true;
dosomething(g);
}
function dosomething(g){
switch (g.str){
case 'hi i am an error':
main();
break;
case 'hi i am an error that was unexpected':
trysomethingelse();
break;
}
wshell.popup(g.str);
}
function trysomethingelse(){
//do something else
}
- Ryan_MoranValued ContributorThere are several ways to do this I'm just providing a simple example for purpose of conceptual design. In my scripts I use a standard set of functions that drive the application(s) back to a point that scripts are able to resume from. I.E. Restart all applications, login, get back to the main form, resume where I left off.
- pravin_k99ContributorThanks Jose,
But I cant add If Exits for eash step as I have around 10,000 objects mapped and several hundred tests using them
Its just that due to the performance of the VM we are running the test on, sometime the object come into memory a little late. Hence when the object is not found, I wanted the test to not stop rather just retry the same statement again.
Thanks Ryan/Gena
I shall try to see if I can implement something like this.
BTW. can you please send me the VB Script version of a script, which catched the error and then goes back to same step which caused it. I just want the execution control to be transferred to the same place once, if it fails again then there is a genuine problem with the object and it can fail the next time.
Thanks
Pravin - jose_pitaSuper ContributorI don't use name mapping, I always use the same function to click any object with parameters such as objectPropertyName and objectPropertyValue accepting arrays too (just did this in a hurry, can have some mistakes)
function waitForObjectAndClick(objectPropertyName, objectPropertyValue, maxTime)
{
//maxTime is in seconds
if(maxTime == undefined)
maxTime = 5
var obj,counter;
counter = 0;
while(!obj.Exists || obj == null || obj == undefined)
{
obj = sys.browser.page.find(objectPropertyName,objectPropertyValue, 30, true);
delay(1000);
counter++;
}
if(counter==maxTime)
{
Log.Error("UPS!");
Runner.Stop();
}
}
Related Content
- 2 years agoTestQA1
- 3 years agoMis3
- 12 months agodhundley
- 6 years agoJakemorley
Recent Discussions
- 3 days agovladd1