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 Ambassador
    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
Sign In or Register to comment.