Working with Canvas Elements

Hi,
Currently I am trying to automate games which are developed using Canvas tag.

This game has buttons like play, help etc which I want to automate.
Is there any possible way to automate these canvas elements using Katalon studio?

Sheetal

sheetal sulay said:

Hi,
Currently I am trying to automate games which are developed using Canvas tag.

This game has buttons like play, help etc which I want to automate.
Is there any possible way to automate these canvas elements using Katalon studio?

Sheetal

Anyone has any idea around this?

Sheetal

Not sure what is the question, but I will take a wild guess. Maybe try WebUI.switchToFrame() before working with canvas. Again, I’m not sure this will work, since I didn’t work with canvas, but hope it helps.

Thank you @Mate Mrse for responding.
Let me explain the issue.

I am doing game automation. The game in included withing single canvas element. So I am doing below to automate the game:-

WebUI.switchToFrame(findTestObject(‘Page_GameLaunch/frm_Game’),500)

WebUI.waitForElementVisible(findTestObject(‘Page_GameLaunch/canvas_Game’), 50)

WebUI.clickOffset(findTestObject(‘Page_GameLaunch/canvas_Game’),649,-166)

WebUI.clickOffset(findTestObject(‘Page_GameLaunch/canvas_Game’),666,384)

This is working fine.But this solution is not feasible as we have to find out the co-ordinates every time. So my question was to look for any other solution by which we do not need to provide co-ordinates for clicking.

Regards,
Sheetal

2 Likes

Sheetal,
I’m a step behind you on this, how can I pull the coordinates needed?
after that i’m also going to be looking for a better solution.

Hi Anthony,

I used selenium recorder to get the desired co-ordinates.

Sheetal

1 Like

**Working with Canvas in Edge browser

**I work with canvas in my application. Chrome browser click the middle of the canvas using the action “focus” and “doubleClick”. The doubleClick/click action brings a slider window as expected in Chrome. Whereas in Edge browser, the canvas is recognised as elementPresent == true, but the doubleClick does not show the slider window. The Katalon script result shows the doubleClick action as ‘pass’ in Edge. But the slider window does not show up in the application. how to find in which coordinate, the script clicks on the canvas? Please assist. Thanks.

Hi Sheetal,

Did you found any better/feasible solution for this ?

Regards,
Abhishek

try to get size of the canvas i.e., height and width
height = WebUI.getElementHeight(findTestObject('Object Repository/##)
width = WebUI.getElementWidth(findTestObject('Object Repository/#pollafter that
WebUI.clickOffset(findTestObject(‘Page_GameLaunch/canvas_Game’),height1/5,width1/5)
if you want to do from centre than use 1/2

I hope my solution helps you