User code to click on Chrome page based on image recognition

Ask general questions here.
User avatar
szohar
Posts: 6
Joined: Tue Oct 15, 2013 5:57 pm
Location: Southeastern Florida, United States

User code to click on Chrome page based on image recognition

Post by szohar » Tue Oct 15, 2013 7:09 pm

Hello all,

I am trying to build user code that clicks on a specific portion of a Chrome web page based on image recognition.

My test case has to access an intranet site that initially triggers a security certificate error. In IE and Firefox, I can access the actual page elements for the security certificate error screen, and click on the appropriate links/buttons to handle the security certificate issue without using image recognition.

Since Chrome doesn't expose the page elements for the security certificate error screen, I have been trying to get around this by using image-based click logic.

Using the Ranorex Recorder, I've been able to used image recognition to click on the correct spot on the screen.

However, I can't seem to make the logic work as user code, which I would prefer to do, because I only want to invoke the image recognition click logic if the browser is Chrome.

If I use the Convert to User Code function to convert the recorder code to user code, this is what it shows up as:

Report.Log(ReportLevel.Info, "Mouse", "(Optional Action)"+Chr(13)+""+Chr(10)+"Mouse Left Click item 'MQTaskAddDonor.DivTagLga' at Center.", repo.MQTaskAddDonor.DivTagLgaInfo)
MyRepo.MQTaskAddDonor.DivTagLga.Click(new Location(DivTagLga_ChromeScreenShotDiv, DivTagLga_ChromeScreenShotDiv_Options))

However, if I try to use the second line of that code in the user code logic that actually checks for the certificate error, I get the following build errors:

'DivTagLga_ChromeScreenShotDiv_Options' is not declared. It may be inaccessible due to its protection level. (BC30451)

'DivTagLga_ChromeScreenShotDiv' is not declared. It may be inaccessible due to its protection level. (BC30451)

What am I doing wrong? Any help would be appreciated.
Quality is not an act, it is a habit. - Aristotle

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

Re: User code to click on Chrome page based on image recognition

Post by krstcs » Wed Oct 16, 2013 1:56 pm

For some things Chrome hides the inner structure unless you pass a parameter. I'm not sure if this will work in your case, but you could try the solution posted here: http://www.ranorex.com/forum/unable-to- ... t5102.html.

It discusses using the "--force-renderer-accessibility" parameter when you start Chrome, which tells Chrome to render all accessibility objects, which it doesn't do by default.
Shortcuts usually aren't...

User avatar
szohar
Posts: 6
Joined: Tue Oct 15, 2013 5:57 pm
Location: Southeastern Florida, United States

Re: User code to click on Chrome page based on image recognition

Post by szohar » Wed Oct 16, 2013 4:04 pm

That Chromium parameter did the trick! Thank you so much!
Quality is not an act, it is a habit. - Aristotle