not able to identify element, stuck due to this.

Ask general questions here.
sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

not able to identify element, stuck due to this.

Post by sdimbre » Thu Sep 08, 2011 11:19 am

Hi Team,

My use case is something like select a text form MS word page, right click and select 'Font' from context menu appeared, as shown in attachment. Using word libraries I have done comfortably till right click and open context menu but not able to identify 'Font' menu item using ranorex :cry: . Is there any way to do that?

For every item on the context menu SPY gives same xPath like "/form[@class='']/container/container/container/contextmenu/container/menuitem". However SPY does not give screenshot for this element.

Note: To track through ranorex spy, I am first setting track on. Then turning back to word page (alt+tab)pressing properties key on keyboard and then setting spy tracker here.

Thanks,
Dimbre
You do not have the required permissions to view the files attached to this post.

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

Re: not able to identify element, stuck due to this.

Post by Support Team » Thu Sep 08, 2011 1:08 pm

Hi,

Do you have tried to use our "instant tracking" functionality as it is described in the specific section of the UserGuide?
If yes, which version of the MS Word are you using?

Regards,
Markus
Ranorex Support Team

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: not able to identify element, stuck due to this.

Post by artur_gadomski » Tue Sep 13, 2011 9:07 am

You can also see if you can use some workaround ie. You can select Font by pressing Alt+F on a keyboard.

sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

Re: not able to identify element, stuck due to this.

Post by sdimbre » Fri Sep 16, 2011 5:44 am

Team,

Much thanks for your reply. Presently I am out of seek leaves, will try this and let you know.

Thanks,
Dimbre

sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

Re: not able to identify element, stuck due to this.

Post by sdimbre » Mon Sep 19, 2011 11:41 am

Hi Team,

As explained above I have tried 'Instant Tracking', spy able to give xPath for this context menu item but still this is not working. Please look at code below I have written. Your help on this regard is much appreciate as this is blocking my decision.

// to find context menu item
Ranorex.Core.Element clkMenu = myPage.FindSingle(".//contextmenu[@processname='WINWORD']/contextmenu/menuitem[@accessiblename='Font']");
//positioning the cursor on menu item
Cursor.Position = new Point(clkMenu.ScreenLocation.X, clkMenu.ScreenLocation.Y);
//firing left mouse click event.
mouse_event(0x0002, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
mouse_event(0x0004, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);

In above code I am trying to click on Font menu. I am working on windows 2007.

Give following exception.
e = {"No element found for path './/contextmenu[@processname='WINWORD']/contextmenu/menuitem[@accessiblename='Font']'."}

Thanks,
SDimbre..
Last edited by sdimbre on Tue Sep 20, 2011 8:01 am, edited 2 times in total.

sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

Re: not able to identify element, stuck due to this.

Post by sdimbre » Tue Sep 20, 2011 6:25 am

Support Team wrote:Hi,

Do you have tried to use our "instant tracking" functionality as it is described in the specific section of the UserGuide?
If yes, which version of the MS Word are you using?

Regards,
Markus
Ranorex Support Team
Hi Team,

As explained above I have tried 'Instant Tracking', spy able to give xPath for this context menu item but still this is not working. Please look at code below I have written. Your help on this regard is much appreciate as this is blocking my decision.

// to find context menu item
Ranorex.Core.Element clkMenu = myPage.FindSingle(".//contextmenu[@processname='WINWORD']/contextmenu/menuitem[@accessiblename='Font']");
//positioning the cursor on menu item
Cursor.Position = new Point(clkMenu.ScreenLocation.X, clkMenu.ScreenLocation.Y);
//firing left mouse click event.
mouse_event(0x0002, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
mouse_event(0x0004, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);

In above code I am trying to click on Font menu. I am working on windows 2007.

Give following exception.
e = {"No element found for path './/contextmenu[@processname='WINWORD']/contextmenu/menuitem[@accessiblename='Font']'."}

Thanks,
SDimbre..

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

Re: not able to identify element, stuck due to this.

Post by Support Team » Tue Sep 20, 2011 8:31 am

Hi,
sdimbre wrote:As explained above I have tried 'Instant Tracking', spy able to give xPath for this context menu item but still this is not working. Please look at code below I have written. Your help on this regard is much appreciate as this is blocking my decision.
Do you open the context menu first with rightclicking or are you searching instantly for this context menu?
Instead of using ".//contextmenu" use "//contextmenu" and instead of using your whole code with the mouse cursor just use clkMenu.Click();

Regards,
Peter
Ranorex Team

sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

Re: not able to identify element, stuck due to this.

Post by sdimbre » Tue Sep 20, 2011 1:26 pm

sdimbre wrote:As explained above I have tried 'Instant Tracking', spy able to give xPath for this context menu item but still this is not working. Please look at code below I have written. Your help on this regard is much appreciate as this is blocking my decision.
Do you open the context menu first with rightclicking or are you searching instantly for this context menu?
Yes, I open contextmenu first with rightclick and instantly serach for context menu item.
Instead of using ".//contextmenu" use "//contextmenu" and instead of using your whole code with the mouse cursor just use clkMenu.Click();
The reason I was not using 'clkMenu.Click' was that here I am using Ranorex.Core.Element and this does not have Click(). Please check the code below, here I am using this as MenuItem adapter.

Ranorex.MenuItem clkMenu = myPage.FindSingle("//contextmenu[@processname='WINWORD']/contextmenu/menuitem[@accessiblename='Font']");
clkMenu.Click();

Thanks and Regards,
SDimbre

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

Re: not able to identify element, stuck due to this.

Post by Support Team » Tue Sep 20, 2011 3:08 pm

Hi,

does th code you've provided in your last post work for you?
If not, try to record the steps with Ranorex Studio and have a look at generated code.

Regards,
Tobias
Support Team