Need VB example of how to verify whether a dialog exists
Posted: Wed Jul 24, 2013 10:58 pm
Does anybody have a small piece of VB.NET code they can share, as an example of how to verify whether a desktop dialog exists? I have been all other the Forum and User Guide, and I can't seem to find a complete example that does this, "complete" being the key here, with all the Dim statements needed. I do not use the repository; I use the xpath. This is not a web-based product. I include error handling and log errors into a .log file.
This should be really simple, but the correct syntax seems to be evading me.
What I need to do: Look for the titlebar of a dialog that is named "Message" and click on the titlebar. If the titlebar is not found within 1 minute, error out or fail in some way that I can handle it.
Right now, the dialog is not being displayed, so I need to have it go to the error handling, which will enter the failure into a log file.
I'm using Ranorex Studio 4.0.5.
Code I have tried:
In this case, Ranorex.Validate.Exists(xpath, 60000) seems to be ignored, but I don't understand why; I'm error handling for Ranorex.ValidationException, but it never gets into that part of the error handler. Instead, it gets Ranorex.ElementNotFoundException when it tries to do Dim titlebar As New Ranorex.TitleBar(xpath) with message "No element found for path '/form[@title='Message']/titlebar[@accessiblerole='TitleBar']' within 10s.", which is not surprising, but that doesn't help me wait for a specified duration of 60s, instead of the default 10s.
I've tried various ways of using FindSingle with a duration of 60000, but how can I do FindSingle on titlebar if I can't Dim titlebar? When I try to build the test with FindSingle, I keep getting build errors. TryFindSingle does not seem any better than FindSingle.
When the application that is being tested displays the Message dialog, the test code works fine, so it can identify the titlebar when it exists.
Any help is appreciated!
This should be really simple, but the correct syntax seems to be evading me.
What I need to do: Look for the titlebar of a dialog that is named "Message" and click on the titlebar. If the titlebar is not found within 1 minute, error out or fail in some way that I can handle it.
Right now, the dialog is not being displayed, so I need to have it go to the error handling, which will enter the failure into a log file.
I'm using Ranorex Studio 4.0.5.
Code I have tried:
Code: Select all
xpath = "/form[@title='Message']/titlebar[@accessiblerole='TitleBar']"
Ranorex.Validate.Exists(xpath, 60000)
Dim titlebar As New Ranorex.TitleBar(xpath)
titlebar.Click()
I've tried various ways of using FindSingle with a duration of 60000, but how can I do FindSingle on titlebar if I can't Dim titlebar? When I try to build the test with FindSingle, I keep getting build errors. TryFindSingle does not seem any better than FindSingle.
When the application that is being tested displays the Message dialog, the test code works fine, so it can identify the titlebar when it exists.
Any help is appreciated!