I am trying to automate Windchill PLM web application, at one point when I perform right-click, a small window opens but with alert (because user is not permitted to perform further operation). I am trying to accept this alert and end the test.
The real problem here is that small window with alert. Katalon is simply not able to interact with the window as there is already an alert present on it and without switching to that window, I am not able to accept or dismiss the alert.
- Tried with direct acceptAlert
- tried with all switch methods
Please help
Hi
can I ask why you need to accept the alert if you are simply ending the test? If you don’t have permissions then test should verify that this is correct behaviour and end. That would be my simple solution
Hi @Dan_Bown
Actually, it is necessary otherwise how the test will end without validating the same?
And once Katlon understands this, I will also add 1 step to getText from that alert and print it in the log.
Could you tell me how to handle such types of alerts?
When the alert pops up, is it automatically in focus? If so, you could use Robot class to hit the enter key, if that would be appropriate? Eg:
import java.awt.Robot as Robot
import java.awt.event.KeyEvent as KeyEvent
Robot rb = new Robot()
rb.keyPress(KeyEvent.VK_ENTER)
WebUI.delay(1)
rb.keyRelease(KeyEvent.VK_ENTER)
There are some other ideas in this doc:
What does a locator look like for text on the new popup? You mentioned that you’ve tried all of the Switch methods but in my experience it will be one of them. Perhaps use WebUI.getWindowIndex to get your current focus and then work out whether you need to move to another.
Just a note that if you use the Robot, you cannot be playing with the mouse or keyboard at the same time. Otherwise, the Robot steps won’t work! Let the Robot do its thing and if it works, you might give yourself a reminder that anytime you run the test, you can’t play with your keyboard at the same time. Maybe add " - wR" to the test case name.