Katalon Studio v5.8 - It's time for the all-new API testing experience
sheetal sulay
Katalon Apprentice
05/02/2018

Working with Canvas Elements

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

<canvas style="display: block; margin: auto; position: absolute; padding: 0px; width: 1366px; height: 181px;" id="game" width="1366" height="181"></canvas>

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
Upvote
Quote

Comments

  • sheetal sulay
    Katalon Apprentice
    05/15/2018
    Hi,
    Currently I am trying to automate games which are developed using Canvas tag.

    <canvas style="display: block; margin: auto; position: absolute; padding: 0px; width: 1366px; height: 181px;" id="game" width="1366" height="181"></canvas>

    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
    Upvote
    Quote
  • Mate Mrse
    Katalon Expert
    05/15/2018
    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.
    Upvote
    Quote
  • sheetal sulay
    Katalon Apprentice
    05/15/2018
    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
    Upvote
    Quote
  • Anthony Chapman
    Katalon Apprentice
    05/16/2018
    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.
    Upvote
    Quote
  • sheetal sulay
    Katalon Apprentice
    05/17/2018
    Hi Anthony,

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

    Sheetal
    Upvote
    Quote
  • Devipriya Kalaimani
    Katalon Apprentice
    08/27/2018
    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.

    Upvote
    Quote
Sign In or Register to comment.