Click does not always work.

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Click does not always work.

Post by stapes » Thu Oct 01, 2015 4:30 pm

Clicking on an object seems to work intermittently.

Code: Select all

repo.DocumotiveMobile.CogWheel.Click ("20;8");
If I code it to click twice, first time through, it works (presumably because it didn't do the first click).

Second time through - it fails. Unsurprisingly as after the click, the button SHOULD no longer be there.

What is going on here?

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Fri Oct 02, 2015 3:02 pm

Still getting this error. If I code it once, it mostly fails to register the click, and fails on the next command.

If I code it twice, it clicks it once, then can no longer find it to click again - and so fails either way!!!

lucian.teodorescu
Posts: 82
Joined: Fri Oct 24, 2014 10:58 am
Location: Bucharest

Re: Click does not always work.

Post by lucian.teodorescu » Fri Oct 02, 2015 3:52 pm

Hi stapes,

Maybe you should ensure that your element is there. Then focus on it. Then click.

Code: Select all

repo.DocumotiveMobile.CogWheelInfo.waitForExists(5000);
repo.DocumotiveMobile.CogWheel.Self.Focus();
repo.DocumotiveMobile.CogWheel.Click ("20;8");
I hope it helps,
Lucian Teodorescu
NetSun Software

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Mon Oct 05, 2015 10:14 am

Thanks lucian, but that would not compile:

Error 1.

'Ranorex.Core.Repository.RepoItemInfo' does not contain a definition for 'waitForExists' and no extension method 'waitForExists' accepting a first argument of type 'Ranorex.Core.Repository.RepoItemInfo' could be found (are you missing a using directive or an assembly reference?) (CS1061) - C:\Users\stephen.staple\Documents\Ranorex\RanorexStudio Projects\WindowsStaffAppTesting\WindowsStaffAppTesting\ClickAdvancedButton.UserCode.cs:37,45

Error 2:

'Ranorex.Text' does not contain a definition for 'Self' and no extension method 'Self' accepting a first argument of type 'Ranorex.Text' could be found (are you missing a using directive or an assembly reference?) (CS1061) - C:\Users\stephen.staple\Documents\Ranorex\RanorexStudio Projects\WindowsStaffAppTesting\WindowsStaffAppTesting\ClickAdvancedButton.UserCode.cs:38,35

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Mon Oct 05, 2015 10:20 am

Incidentally, these pages appear to be superfluous, in that they contain no useful information whatsoever:

http://www.ranorex.com/Documentation/Ra ... Exists.htm

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Mon Oct 05, 2015 12:38 pm

I found the correct sintax. See below. It didn't work!! It still guarantees nothing!!

Code: Select all

repo.DocumotiveMobile .LoginPage.AdvancedLoginPage.BackButtonInfo .WaitForExists(5000);
			repo.DocumotiveMobile .LoginPage.AdvancedLoginPage.BackButton .Focus();
			repo.DocumotiveMobile.LoginPage.AdvancedLoginPage.BackButton.Click ("24;24");

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

Re: Click does not always work.

Post by krstcs » Mon Oct 05, 2015 1:46 pm

As I wrote in another of your posts, please learn to code in .NET before you attempt to code in Ranorex. If you don't understand the APIs then you should not be using code. Almost everything that you have been asking about can (and should) be done without any coding at all. Read the Ranorex User Guide.

http://www.ranorex.com/support/user-guide-20.html

If you are set on using code, you should learn about .NET first and then the Ranorex API will make more sense to you.
Shortcuts usually aren't...

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Mon Oct 05, 2015 1:52 pm

Thanks but not thanks krstcs. If you don't have anything helpful to add don't bother.

I am writing code because the given functionality is not sufficient for the purpose required.

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Click does not always work.

Post by stapes » Tue Oct 06, 2015 9:22 am

This is what I decided to go with in the end:

Code: Select all

public void GoToAdvancedLoginPage()
        {
        	// we might be on the wrong page
        	// if no button exists, check if is already on StandardLogin Page.         	
         	Report.Log(ReportLevel.Info, "Validation", "Looking for AdvancedLoginButton.", repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButtonInfo);
         	
         	if(repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButtonInfo.Exists(10000))
            {
				Report.Log(ReportLevel.Info, "Validation", "AdvancedLoginButton exists.", repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButtonInfo);
            	Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'DocumotiveMobile.AdvancedLogInButton' at 20;8.", repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButtonInfo);
            	repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButton.Focus();
            	
	            repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButton.Click ("20;8");
	            Report.Log(ReportLevel.Info, "Validation", "AdvancedLoginButton clicked.", repo.DocumotiveMobile.LoginPage.StandardLogInPage.AdvancedLogInButtonInfo);
            }
            else
            {
            	CheckIfStandardLoginPageAlreadyLoaded();
            }

        }

        public void CheckIfStandardLoginPageAlreadyLoaded()
        {
            Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (Text='Back') on item 'DocumotiveMobile.BackButton'.", repo.DocumotiveMobile.LoginPage.AdvancedLoginPage .BackButtonInfo);
            Validate.Attribute(repo.DocumotiveMobile.LoginPage.AdvancedLoginPage .BackButtonInfo, "Text", "Back");
        }
It still does not guarantee arriving at the right page, and I have had to include it twice in a test case to make it work.
This may be where a click has not been registered because it did something else, like make a popup menu go away.