check visibility

Class library usage, coding and language questions.
Felmel
Posts: 7
Joined: Mon Nov 18, 2013 8:13 am

check visibility

Post by Felmel » Fri Feb 07, 2014 1:42 pm

can i program somthing with ranorex like:

if a specific button is visible:
click
else:
....

Does some1 have a code example? Which methode could i use?

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: check visibility

Post by Swisside » Fri Feb 07, 2014 1:58 pm

Hello

You could do something like this :
if (repo.myitem.Visible){
				repo.myitem.Click();
				
			}
			else  {
				Report.Info("Not visible");
break;
			}
Cheers
A simple thank you always does wonders !

Felmel
Posts: 7
Joined: Mon Nov 18, 2013 8:13 am

Re: check visibility

Post by Felmel » Fri Feb 07, 2014 2:19 pm

my problem at the momoent is, if myitem is not visible, the iteration breaks and i wont get into the else line.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: check visibility

Post by krstcs » Fri Feb 07, 2014 2:27 pm

That is probably because you are checking for Visible()==true when you should be checking for Exists()==true.

More than likely the element is not there. Check it with spy and make sure that it is actually existing before you check for visible, because if it isn't there Ranorex won't be able to check if it is visible or not.
Shortcuts usually aren't...

Felmel
Posts: 7
Joined: Mon Nov 18, 2013 8:13 am

Re: check visibility

Post by Felmel » Fri Feb 07, 2014 2:44 pm

ok thats what im looking for....
i just want to know if the button exists
repo.myitem.Exists() == true
does not work for me. What would be the code just for checking if my button exists.

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: check visibility

Post by Swisside » Fri Feb 07, 2014 3:22 pm

Hello

If you want to use Exist() you need to do as follows :

if(repo.MyItemInfo.Exists())
{
Report.Info("It exists");
}
else {
Report.Info("It doesn't!");
}

N.B. Ranorex will search for the item until the timeout specified in the repository is reached. So if you want for Ranorex to be faster you can reduce the search timeout according to how long it usually takes to find the item.


Cheers
Attachments
spytimeout.png
spytimeout.png (10.21 KiB) Viewed 1492 times
A simple thank you always does wonders !

Felmel
Posts: 7
Joined: Mon Nov 18, 2013 8:13 am

Re: check visibility

Post by Felmel » Fri Feb 07, 2014 4:11 pm

thanks.
exactly what i was looking for :D