Page 1 of 1
Difficulty clicking button on web application
Posted: Wed Jan 14, 2015 1:25 pm
by Fergal
[Ranorex 5.2.1, running on Windows 7. Test is failing in Chrome, IE and Firefox.]
I have recorded a test step to click on a button in a web application. Ranorex can find the repository item for the button, however the test run is
not clicking on the button. The error message received is as follows;
Item 'DefectsRepository.Defects.Save_Button_in_Modify_Defect_Dialog' is no Button.
The element does not support the required capability 'button'.
How can I edit the step so that the button is clicked?
Thanks!
Re: Difficulty clicking button on web application
Posted: Wed Jan 14, 2015 1:38 pm
by CookieMonster
HI Fergal,
If don't want to take care of which type the web element is. Your error message says it is not a button.
Then you have to create an new abstract class. In this class you create a public method like
Code: Select all
public void Click_WebButton(RepoItemInfo repoInfo)
{
repoInfo.WaitForExists(new Duration(30000));
var element = repoInfo.CreateAdapter<Unknown>(true);
if(element.Element.FlavorName.Equals("web"))
{
WebElement webElement = element.Element;
webElement.PerformClick(); //or use webElement.Click();
Report.Log(ReportLevel.Success, "Click", string.Format("{0} {1} successfully clicked",element.Element.PreferredCapability.DisplayName, repoInfo.Name));
}
}
After that you can inherit this class in your Recording User File. There you add an user code line, where you call this method, and pass the RepoItem.
Have also a look here:
http://www.ranorex.com/blog/custom-smar ... ns#Example
Cheers
Dan
Re: Difficulty clicking button on web application
Posted: Wed Jan 14, 2015 2:09 pm
by Fergal
Thanks very much for your reply Dan, I appreciate that.
My knowledge of coding tests is limited and if possible, I would prefer to fix the test via the recorder, rather than using code. If it can't be fixed using the recorder, I will try your method.
Thanks again!
Re: Difficulty clicking button on web application
Posted: Thu Jan 15, 2015 2:49 pm
by Support Team
Hi Fergal,
Have you already tried to change the Adapter Type of the specific repository item "Save_Button_in_Modify_Defect_Dialog" to "buttontag"?
This can be done in the properties tab of the specific repo item as you can see below:
ButtonTag.png
Regards,
Markus
Re: Difficulty clicking button on web application
Posted: Fri Jan 16, 2015 11:30 am
by Fergal
Thanks very much for that Markus, it works perfectly and the test is running successfully now. (There wasn't actually an Adapter Type property for button, however, changing it from "Default" to "webelement" resolved the issue).