Hi All,
I wound need to use popupwatcher to detect error popups in my application, but I would screenshot them before click on dismiss button in order to let automatic test to continue.
I am not able to detect/take screenshot/dismiss, but only to detect/dismiss, using StartPopupWatcher method.
Does anybody know how to take screenshot anytime a popupwatcher item is detected?
Do you know any method or do you have any suggestion to achieve it?
Thank you very much in advance for your opinion.
PopupWatcher Screenshot
Re: PopupWatcher Screenshot
Hi,
I'm using a custom StartPopupWatcherAndWatch method, which is derived form StartPopupWatcher. basically, instead of clicking a popup element, it just watch an element and writes about it in report. Simply add these two methods to Automation Helpers > PopupWatcherLibrary and then call StartPopupWatcherAndWatch method in code module, where you initialize your popupwatchers:Hope this helps?
I'm using a custom StartPopupWatcherAndWatch method, which is derived form StartPopupWatcher. basically, instead of clicking a popup element, it just watch an element and writes about it in report. Simply add these two methods to Automation Helpers > PopupWatcherLibrary and then call StartPopupWatcherAndWatch method in code module, where you initialize your popupwatchers:
Code: Select all
/// <summary>
/// Waits for a popup window to appear and write about it in report
/// </summary>
/// <param name="findElement">Element to wait for</param>
/// <param name="watchMethod">Element to click after the popup appears</param>
/// <returns>Reference to a newly created <see cref="PopupWatcher"/></returns>
[UserCodeMethod]
public static PopupWatcher StartPopupWatcherAndWatch(RepoItemInfo findElement)
{
var key = findElement.GetMetaInfos()["id"];
if (watchers.ContainsKey(key))
{
throw new ArgumentException("Popup watcher with given parameters already exists.");
}
var watcher = new PopupWatcher();
watcher.Watch(findElement, watchMethod);
watcher.Start();
watchers.Add(key, watcher);
Report.Info("Popup watcher started.");
return watcher;
}
public static void watchMethod(RepoItemInfo myInfo, Ranorex.Core.Element myElement)
{
Report.Screenshot(ReportLevel.Failure, "PopupWatcher", "An error occured!",myElement.Parent.Parent, true,null);
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: PopupWatcher Screenshot
Thank you for your suggestion.
Since I have also to click the "OK" button of the watched popup, do you think I can use two different popupwatcher methods together?
I mean, StartPopupWatcherAndWatch to take screenshot and StartPopupWatcher to click for dismissing the popup?
Since I have also to click the "OK" button of the watched popup, do you think I can use two different popupwatcher methods together?
I mean, StartPopupWatcherAndWatch to take screenshot and StartPopupWatcher to click for dismissing the popup?
Re: PopupWatcher Screenshot
Hi,
I would defnitely not use StartPopupWatcher and StartPopupWatcherAndWatch for the same element, because they both starts in a separate thread and it may easily happen, that the click is performed before taking the screenshot You can just add click method to watchMethod called from StartPopupWatcherAndWatch. Simply right after the Report.Screenshot action, add Click method. Then you should not need to use two popupwatchers.
I would defnitely not use StartPopupWatcher and StartPopupWatcherAndWatch for the same element, because they both starts in a separate thread and it may easily happen, that the click is performed before taking the screenshot You can just add click method to watchMethod called from StartPopupWatcherAndWatch. Simply right after the Report.Screenshot action, add Click method. Then you should not need to use two popupwatchers.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: PopupWatcher Screenshot
Exactly...
That was what I tried to do before post the question, but I didn't know how to pass the click element to callback method...
Should I find a way to identify the button starting to the passed "RepoItemInfo findElement"?
Re: PopupWatcher Screenshot
Ok, got it, it works, thanks.
I didn't catch how to pass the click item, but I had it alreay.
Thank you.
I didn't catch how to pass the click item, but I had it alreay.
Thank you.
Re: PopupWatcher Screenshot
Hi,
It was very helpful.
As I'm new to the Codework, will you please share the coding to add click method to watchMethod called from StartPopupWatcherAndWatch?
Thanks
It was very helpful.
As I'm new to the Codework, will you please share the coding to add click method to watchMethod called from StartPopupWatcherAndWatch?
Thanks