How to find the elemnet from Visible Area of desktop?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

How to find the elemnet from Visible Area of desktop?

Post by aravin » Tue Jun 16, 2015 8:31 am

Hi Team,

I want to find the elemnt from the visible area of the desktop! How to get the visible element alone?

Find the attachment below for better understanding.
image00.png
Methods I followed,

1. Foreach

Code: Select all

				IList<Container> tocThumbList=repo.appName.toc.tocContainer.FindChildren<Container>();
				foreach(var tempThumb in tocThumbList)
				{
					if(tempThumb.Element.GetAttributeValueText("Caption")=="46-47" && tempThumb.Element.Visible)
					{
						tempThumb.Click();
						Report.Info("Element Found...");
					}
				}
2. For Each loop.

Same code with foreach loop.

------------------
Currently this code is getting all the thumbnails from the container, which are not visible in the desktop screen.

Is there any alternative solution to find and click the elemnt which are visible in this current screen. It should not find the hidden thumbnail.

Thanks in advance. 8) :P
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to find the elemnet from Visible Area of desktop?

Post by odklizec » Tue Jun 16, 2015 9:19 am

Hi,

As I mentioned in your other post on this subject, to find if the element is outside the visible area of screen you will most probably have to calculate it from screen resolution (desktop size) and element position on desktop. If the element position is outside the screen resolution/desktop size, it's clearly in non-visible area of desktop ;)

However, I think EnsureVisible() should do the trick and bring the element to visible area of screen.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

Re: How to find the elemnet from Visible Area of desktop?

Post by aravin » Tue Jun 16, 2015 9:39 am

Hi,

I am already using EnsureVisible(). It is not working.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to find the elemnet from Visible Area of desktop?

Post by odklizec » Tue Jun 16, 2015 9:44 am

Even after disabling the mouse option I mentioned in second post? In this case, your only chance is to get the thumbnail position and compare it with desktop area/screen resolution.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

Re: How to find the elemnet from Visible Area of desktop?

Post by aravin » Wed Jun 17, 2015 7:15 am

Hi Odklizec,

Thanks a lot.

Old Code

Code: Select all

if(tempThumb.Element.GetAttributeValueText("Caption")==thumbName )
New Code

Code: Select all

if(tempThumb.Element.GetAttributeValueText("Caption")==thumbName  && repo.browserScreen.Self.ScreenRectangle.Contains(tempThumb.Element.ScreenLocation)
This worked for me.

I have taken the browser screen rectangle size and verified that the thumb element position before clicking the element.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to find the elemnet from Visible Area of desktop?

Post by odklizec » Wed Jun 17, 2015 7:23 am

Hi,

You are welcome. Nice to hear you solved the problem.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration