How to click video play button in Chrome

Best practices, code snippets for common functionality, examples, and guidelines.
CWhiting
Posts: 11
Joined: Thu Mar 08, 2018 9:32 pm

How to click video play button in Chrome

Post by CWhiting » Wed Jan 02, 2019 7:37 pm

We have a video element that I need to click the play arrow button to start the video play back. Previously, the play button was the center of the video and I could just to a click on the video element. Now, not sure if the browser or our product has changed, the center play button is not active only the lower left-hand side button.
VideoPlayer.JPG
Clip of the video element
VideoPlayer.JPG (70.53 KiB) Viewed 197 times
All of my tests are written in C#, how can I initiate the playback reliably?

Firefox still shows the center play button, but I am testing with Chrome.

One approach would be to search the video element for the playback arrow. So far I have not been successful with that approach. I have found a need for additional tools to work with image. I tried the recorder and when I played the recording back, the element could not be found.

The approach I am taking now is to click at a specific offset from the bottom and left edge of the video element rectangle. This is not a good approach for a reliable test.

Other suggestions??

User avatar
Support Team
Site Admin
Site Admin
Posts: 11978
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to click video play button in Chrome

Post by Support Team » Wed Jan 02, 2019 9:26 pm

Hi CWhiting,

Since the video player is part of the Chrome browser and not the dom, you will need to turn on accessibility to access this Chrome object with Ranorex. To turn on accessibility, navigate to chrome://accessibility/ in Chrome and enable Native accessibility API support and Web accessibility. Now that accessibility is enabled, you can use the following RxPath to point to the play/pause button.

Code: Select all

/form[@processname='chrome']//button[@accessiblename='play']
Alternatively, you can perform a click on the video window at specific x;y coordinates by using one of the Click overloaded methods. Note, the x, y coordinates specified are relative to the specified element's location. For example: 0, 0 = top left corner of the specified element, while 100, 600 = 100 pixels right and 600 pixels down from the top left corner. You can also go up and left by using negative x, y coordinates.

Code: Select all

repo.Chrome.VideoWindow.Click(new Location(100, 600));

I hope this helps!

Cheers,
Ned
.
Image