JohnSnikersOccasional ContributorJoined 7 years ago13 Posts2 LikesLikes received1 SolutionView All Badges
ContributionsMost RecentMost LikesSolutionsRe: Dynamically changing UnexpectedWindows handling Sorry, my example was not correct, please check the .ClickButton() methods : function ProjectEvents_OnUnexpectedWindow(Sender, Window, LogParams) { Window.Activate(); myApp = Aliases.MyApp; var String1 = "The last "; var String2 = "Number of"; //..orders/days/items var String3 = "There are"; //..1/2/3/4/5/6..orders! or Validation failed! There are ....orders! switch(Window.MappedName) { case "Aliases.MyApp.frmMain": Log.Warning("MyApp was handled as 'Unexpected' window"); break; case "Aliases.MyApp.dlgApp": var message = myApp.dlgMyApp.Child(myApp.dlgMyApp.ChildCount - 1).Name; if(message.includes(String1)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),true); myApp.dlgMyApp.btnYes.ClickButton(); break; } else if(message.includes(String2)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),false); myApp.dlgMyApp.btnYes.ClickButton(); break; } else if(message.includes(String3)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),true); myApp.dlgMyApp.btnNO.ClickButton(); break; } } else if(message.includes(String3)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),true); myApp.dlgMyApp.btnOK.ClickButton(); break; } } As you can see, I have to handle them differently because each of them has different button as well... :( Therefore your reorganized code would cause failure. Sorry for giving bad example. Dynamically changing UnexpectedWindows handling Hi, There are a lot of unexpected windows/dialogboxes with different messages poping up in my application during test runs. Since the text of the popup windows changes dynamically I'm not able to tell which appears when so I'm not able to tell if it's an actual error or just a popup window. I figured out the following solution: function ProjectEvents_OnUnexpectedWindow(Sender, Window, LogParams) { Window.Activate(); myApp = Aliases.MyApp; var String1 = "The last "; var String2 = "Number of"; //..orders/days/items var String3 = "There are"; //..1/2/3/4/5/6..orders! or Validation failed! There are ....orders! switch(Window.MappedName) { case "Aliases.MyApp.frmMain": Log.Warning("MyApp was handled as 'Unexpected' window"); break; case "Aliases.MyApp.dlgApp": var message = myApp.dlgMyApp.Child(myApp.dlgMyApp.ChildCount - 1).Name; if(message.includes(String1)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),true); myApp.dlgMyApp.btnYes.ClickButton(); break; } else if(message.includes(String2)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),false); myApp.dlgMyApp.btnYes.ClickButton(); break; } else if(message.includes(String3)) { DevLogMessage("The text of the popped up window: " + TrimMessage(message),true); myApp.dlgMyApp.btnYes.ClickButton(); break; } } This is not the whole script just a snippet but you can imagine more else if cases.. This is a working solution and unexpected/popup windows will be handled as I want them. BUT it is a bit slow and since there are a tons of times this event is going to be activated this slowness adds up and the test execution time grows. I know it is mostly because of the (message.includes(String)) statement, everytime it has to check the whole Message if it includes the given string even if the first part of it is different. But it is kind of a must have way because I don't know which part of the dialogbox's message will contain the string which helps me to decide which button to Click on. I hope you can understand the problem and why it is solved like this. If you have a better idea/way to solve this problem please feel free to tell me Anything useful is truly appriciated Thank you Re: Make it possible to export from the log the records of only certain type(s) Any update about this request? Unexpected window eventhandler activation Hi, There are many different unexpected windows in my TestApplication so I created an Unexpected Window Event Handler to be able to handle all of them. (Different texts, buttons and have to handle most of them differently, for instance sometimes press buttonYes or press buttonNo) But the problem is it won't run after each action for example there are scenarios where function sample(){ Menu.Click("Main menu"); --Unexpected window-- testapp.menuMain.Close(); } And it can't handle the unexpected window or if it can, then the .Close action won't be executed. Or function sample(){ Menu.Click("Main menu"); testapp.menuMain.Close(); --Unexpected window-- Menu.Click("Other menu"); } In this case if the unexpected window will be closed, then the Menu.Click("Other menu"); won't be executed. So the question is how to create a proper unexpected window handler which runs/is active between each action without any hardcoding in the sample function. Please help me understand the problem and not just link the documentation about how to create eventhandlers.. I already read it. Thank you SolvedRe: Autoincrementing project variables dinamically Thank you, it worked Autoincrementing project variables dinamically Hi, I would like to write a function in JS which automatically increments the value of the given project variable as parameter dinamically. Something like: function AutoIncrement(variable){ Project.Variables.$set("VariableByName", variable, ++Project.Variables.$variable); } Im not sure how this Project.Variables.$set function works but I guess this is what I need. I have used it before for setting some bool project variables to false without knowing there exact names. Obviously it would work only with integers, but that's fine by me. If possible please give me some examples of the use of $set. Thanks SolvedRe: Appending code to an existing Script not working tristaanogre Thank you for your help btw Re: Appending code to an existing Script not working If anyone had the same issue, the offical response is the following: "This functionality was removed in one of the previous releases. Good news is that it should be returned in our next release that is planned for January." Re: Appending code to an existing Script not working I use JavaScript as well.. If I click into the //cursor here line and press record script, a 'Select Script Unit' window pops up. Which as I recall should not pop up. Re: Appending code to an existing Script not working Yea and the feature was implemented years ago and now it's missing again...