Difficulty clicking button on web application

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Difficulty clicking button on web application

Post by Fergal » Wed Jan 14, 2015 1:25 pm

[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!

CookieMonster
Certified Professional
Certified Professional
Posts: 74
Joined: Mon Aug 14, 2006 7:17 pm
Location: CH

Re: Difficulty clicking button on web application

Post by CookieMonster » Wed Jan 14, 2015 1:38 pm

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

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Difficulty clicking button on web application

Post by Fergal » Wed Jan 14, 2015 2:09 pm

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!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Difficulty clicking button on web application

Post by Support Team » Thu Jan 15, 2015 2:49 pm

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
You do not have the required permissions to view the files attached to this post.

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Difficulty clicking button on web application

Post by Fergal » Fri Jan 16, 2015 11:30 am

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).