Contributions
Re: 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.995Views0likes1CommentDynamically 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 you1KViews0likes3CommentsUnexpected 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 theMenu.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 youSolved1.4KViews0likes2Comments- 1.3KViews1like0Comments
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. ThanksSolved1.3KViews0likes2Comments- 2.1KViews0likes0Comments