Page 1 of 1

Can't automate a right click on a spantag

Posted: Mon Apr 07, 2014 8:39 pm
by kthomp
I am attempting to automate a right-click on highlighted text that is a spantag.

This is the C# code that I am trying to use to set up the keyword:
switch (objEle.PreferredCapability.DisplayName)
{
case "DivTag":
DivTag _divTag = (DivTag)objEle;
_divTag.Click(System.Windows.Forms.MouseButtons.Right);
break;
case "SpanTag":
SpanTag _spanTag = (SpanTag)objEle;
_spanTag.Click(System.Windows.Forms.MouseButtons.Right);
break;
default:
Ranorex.WebElement ele = objEle;
ele.Click(System.Windows.Forms.MouseButtons.Right);
break;

I can't figure out how to get the information from Spy to show on this forum (otherwise I would show this as well). I am using Ranorex 4.1.

It pops up a window, but it is not the window I am expecting.

Re: Can't automate a right click on a spantag

Posted: Mon Apr 07, 2014 9:07 pm
by krstcs
First, all html tags in Ranorex (divtag, spantag, etc.) are derived from webelement, so you can just cast the object as a webelement and click on it so you don't have to do the select-case.

((WebElement)objEle).Click(WinForms.MouseButtons.Right);

As for why you are getting a different popup than you expect, are you sure you are clicking on the correct object? Are you sure that the object you are clicking on brings up the correct dialog? There are many routes with this one, and without knowing your application under test, there is no way for us to tell.

Could you post a snapshot of the application (or send it to [email protected])? See the following link for information on creating snapshots with Ranorex: http://www.ranorex.com/support/user-gui ... files.html