Hi everyone,
I would like to add custom PopupWatcher to handle the dialog that can possibly come up during test run.
I added Ranorex Automation Helpers that contains the PopupWatcher Library , but this set of methods does not contain one that can provide me with function call back, something like public static PopupWatcher StartPopupWatcher(RepoItemInfo findElement, MyCallBackMethod), where I can add some custom code for steps within call back method. I need not only close popup dialog but also perform a few steps as result of this dialog appearance.
Can someone help me with how I can add such method.
Where I should initialize PopupWhatcher? How I should add it to recording module?
If some one got an example of such kind of PopupWatcher and can share with me it will be much appreciated.
Thanks,
Felix
How to add custom PopupWatcher.
Re: How to add custom PopupWatcher.
There are some great code examples in the user guide to help you get started with this (see: "Handling unexpected dialogs
") - https://www.ranorex.com/help/latest/han ... -examples/. This should be initialized and started before the popup can exists. Generally this is the in a [SETUP] region of the test suite, but really can be anywhere you see fit.
") - https://www.ranorex.com/help/latest/han ... -examples/. This should be initialized and started before the popup can exists. Generally this is the in a [SETUP] region of the test suite, but really can be anywhere you see fit.
Code: Select all
void ITestModule.Run()
{
// Create PopupWatcher
PopupWatcher myPopupWatcher = new PopupWatcher();
// Add a Watch using a RanoreXPath and triggering the Method CloseUpdateCheckDialog
myPopupWatcher.Watch("/form[@controlname='UpdateCheckForm']/button[@controlname='m_btnClose']", CloseUpdateCheckDialog);
// Add a Watch using the info object of a button and triggering the Method CloseUpdateCheckDialog
// myPopupWatcher.Watch(repo.UpdateCheckDialog.btCloseInfo, CloseUpdateCheckDialog);
// Add a Watch using the info object of the dialog and the info object of the button to click
// myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog.SelfInfo, repo.UpdateCheckDialog.btCloseInfo);
// Add a Watch using a repository folder object and the info object of the button to click
// myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog, repo.UpdateCheckDialog.btCloseInfo);
// Start PopupWatcher
myPopupWatcher.Start();
}
public static void CloseUpdateCheckDialog(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
{
myElement.As<Ranorex.Button>().Click();
}
public static void CloseUpdateCheckDialog(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement)
{
myElement.As<Ranorex.Button>().Click();
}
Re: How to add custom PopupWatcher.
Hi N612,
Thanks for replying me.
Yes, I read this example, But I can't get how call back method gets element to click on.
I have to analyse if button enabled or disabled within dialog and then perform same steps.
Thanks,
Felix.
Thanks for replying me.
Yes, I read this example, But I can't get how call back method gets element to click on.
I have to analyse if button enabled or disabled within dialog and then perform same steps.
Thanks,
Felix.
Re: How to add custom PopupWatcher.
Thanks everyone.
I found solution.
I found solution.