3

We have automated a few test cases using the Ranorex automation framework for a Silverlight web application. These test cases involve clicking buttons in order to invoke certain messages on the screen. In order to grab the button on the screen, we first create an Ranorex button object and then point it to the appropriate element using Ranorexpath. Then, we use the RanorexButton.Click() event to click the button. However, this event is unreliable. It works sometimes and at other times the button is not clicked. When the button is not clicked, we have to run the test case again from the start. What are we doing wrong? If this is a known problem of ranorex, please suggest workarounds.

R.S.K
  • 2,114
  • 4
  • 26
  • 32

4 Answers4

2

I was facing the same problem but I am able to resolve the problem by introducing a Validate.Exists(infoObject) just before the click. Please make sure that you pass infoObject of your button or any element in Validate.Exists API.

Example:

Validate.Exists(repo.MyApp.LoginBtnInfo);
var button = repo.MyApp.LoginBtn;
button.Click();

With regards, Avinash Nigam

aviundefined
  • 802
  • 2
  • 10
  • 25
1

I haven't heard about such a problem with Ranorex yet, maybe this is just a timing issue. You could add a Validate.Exists(yourButton) right before the click, this ensures that the click is performed after the button was successfully loaded. If it is a WebElement you could also use the PerformClick() method instead of the normal Click() method. There are also different methods which will ensure that the button is in the visible area and has focus, like the EnsureVisible() or the Focus() method. You will find the available methods of the used adapter in the online API of Ranorex.

  • Yup we are using `Focus()` method, but still this issue occurs.... What we have also tried is to use the `click()` event at least couple of times or more. Another workaround is to keep clicking the button till it is visible.... of course this cannot be used if the button does not load another page or is still present after the click event. – R.S.K Feb 01 '13 at 09:29
1

If the Button is not within the area you can see without scrolling, you can use a

var button = repo.Buttons.button1;
button.EnsureVisible();
button.Click();

In this way the button is forced to be watched.

squietschi
  • 71
  • 1
  • 7
1

It might as well be an issue with the xpath and element Id-s.

If you have changing element Id-s even when the page is navigated away from and moved back (for example we have this issue with SAP related components) you might need to make a more robust xPath path variable using regular expressions.

Try to find object and parts of the path that do not change (eg. "iFrame id="MainContent"" or "btn id="ID_XXXX_Search_Button"") - ofcourse this will only help if the issue is within this.

Ranorex Regular Expression info can be found here: http://www.ranorex.com/support/user-guide-20/ranorexpath.html#c3294

A quick example of what I'm talking about:

Let's say we have an input field that has a changing ID in it's name:

US_EL.ID_F2B49DB60EE1B68131BD662A21B3432B:V_MAIN._046A-r

And I know that the part in the Id that doesn't change is:

:V_MAIN._046A-r

I can create a path for this searching the element by the ending of the elements' id that doesn't change using regular expression:

/dom[@domain='test.example.com']//iframe[#'identifier']//iframe[#'identifier2']//input[@id**~'^**:V_MAIN._046A-r']

The bold part will specify to search for an input element with an Id that ends with ":V_MAIN._046A-r".

An issue that might arrise from this is if you have elements using partially the same names you might get multiple elements returned for the same path. So it's wise to add a few more certain points to the path (eg. "iframe[#'identifier2']") when this issue arrises.

Martin
  • 575
  • 6
  • 13