HomeKatalon Studio

Automating Games using Katalon Studio

Automating Games using Katalon Studio

<<Complete Tutorial>>       Next Post>>

Are you searching for the resources, which help you in learning the ways to Automate Game Applications?

Are you facing issues, while trying to identify or locate the UI elements displayed in the Games?

Are you simply performing click operation on Game screen (which blindly clicks on the screen), instead of locating and performing operations on the required UI elements on Game screen?

Then you are at the right place.

In this article, I am going to solve this problem and help you understand in automating the Games easily using Katalon Studio Test Automation Tool.

Prerequisites:

  1. Create an account for Katalon Studio at www.katalon.com
  2. Download and Open Katalon Studio in your Windows Machine
  3. Install Java in your machine

Automating Games using Katalon Studio

Automating the Games or flash Games created using feature of HTML5 like Canvas is always seems to be a challenging task and is difficult to automate using other Test Automation tools.

In Selenium, if we have to automate such Games, we need to use the third party Sikuli along with Selenium.

Or we can use Sikuli to perform this automation using its Image Recognition Technique.

But, using Katalon Studio, we can automate Games with or without using Sikuli.

In this article, I am going to explain automating the Games using Katalon Studio (Without Sikuli integration).

Lets get started with the below topic.

Challenges in Automating Casino Game Applications

Casino Game Applications, generally do not have locators for identifying particular elements while playing them.

And if you try to inspect any UI element, you will see that everything is in canvas (which makes our identification of locators for elements not possible)

To understand automating such kind of Games, I would like to take an example say ‘Paytable’ section in the Casino Game and explain you in a step by step manner on how to automate it.

Example for Automating Game functionality using Katalon Studio:

First lets understand, what needs to be automated by going through the below steps:

1) We first need to open Game in the browser say Chrome of Windows Machine & maximize the browser and then click on ‘Click here to play’ button (shown below):

Katalon Studio - Automating Games - Play Button

2) In the Game, click on the ‘info’ button (shown below):

Katalon Studio - Automating Games - Info Button

3) In the Game application, click on the ‘forward’ button to see all the paytable screens.

Katalon Studio - Automating Games - Forward Button

Now, we know what need to be automated in the Game.

But, on trying to inspect all the above mentioned UI elements (i.e. Play, Info and Forward Buttons), we will not be able to identify the Locators for locating these Buttons.

So, lets get started for solving this problem using the below steps:

1) Open Katalon Studio

2) Create New Project by selecting File Menu > New > Project option (shown below):

Katalon Studio - Automating Games - New Project

3) Give any name to your project say and click on ‘OK’ Button

4) Now create Test Case. Right click on the ‘Test Case’ from the default loaded Project template and click on ‘New’ > ‘Test Case’ option > Give Some Test Case name and click on ‘OK’ button (shown below):

Katalon Studio - Automating Games - New Test Case

5) Click on the ‘Record Web’ option (shown below)

Katalon Studio - Automating Games - Web Recorder Option

6) Add the URL of the Game in the ‘URL’ field of ‘Web Recorder and select ‘Browser’ in which the Game is opened in your machine and click on ‘OK’ Button:

Katalon Studio - Automating Games - Game URL and Browser Selection

7) Now the Web Recorder is on in your machine. While the recorder is on, let’s perform the beginning mentioned Example Scenario (i.e. Play Game, Click Info Button and Click Forward Button in the Game loaded in Browser). You will see the recorded steps in Manual and Script Modes (Shown below).

Manual Mode:

Katalon Studio - Automating Games - Manual Mode Recorded Steps

Script Mode:

WebUI.openBrowser('')

WebUI.navigateToUrl('Url of game')

WebUI.click(findTestObject('Object Repository/images/<strong>Page_Nameofgame/use'))

WebUI.click(findTestObject('Object Repository/images/<strong>Page_Name ofgame/canvas'))

WebUI.click(findTestObject('Object Repository/images/Page_nameof game/canvas'))

WebUI.click(findTestObject('Object Repository/images/Page_nameofgame/canvas'))

WebUI.click(findTestObject('Object Repository/images/Page_nameofgame/canvas'))

WebUI.click(findTestObject('Object Repository/images/Page_nameofgame/canvas'))

WebUI.closeBrowser()

In the above Script Mode, observe that same locator paths are recorded for all the Buttons. (i.e. Dummy/Invalids locators got recorded)

Hence on executing the above recorded Automation script, the Application URL will be opened in the selected browser, but the Button clicks will be not be performed due to invalid or dummy recorded locators.

Lets resolve this problem by following the below steps.

8) Go to, Object Repository in Katalon Studio Project Template, right click on it and select ‘New’ > ‘Test Object’ option as shown below and give any Test Object Name & click on ‘OK’ Button:

Katalon Studio - Automating Games - Creating Test Objects

9) Now capture the image of the ‘Play’ Button on the Game Application using any screen capture tool as shown below and save it on your Machine.

Katalon Studio - Automating Games - Play Button

10) Double click on the Test Object created in Step 8 and select to Browser the Image captured & saved in Step 9 (shown below). Also, check the checkbox option above this Browse field (shown below)

Katalon Studio - Automating Games - Browser Image of Play Button

 

11) Similarly, add more Test Objects for other Buttons by Browsing their images in the same way we did for ‘Play’ Button in the previous steps (shown below).

Katalon Studio - Automating Games - All Three Buttons

12) Now, we got our Test Objects ready. Let’s open the Test Case having the earlier recorded steps in Script mode (As explained in Step 7) and modify the script as below (Understand the below script using the comments mentioned in it):

//Open browser
WebUI.openBrowser('')
//Navigate to browser
WebUI.navigateToUrl(‘URl of game')
//Maximize the browser
WebUI.maximizeWindow(FailureHandling.CONTINUE_ON_FAILURE)
//Wait for the image to display
Thread.sleep(30000)//Instead of hard wait which wait we can use ?I shall explain in next post
// Click on the play button - Observe that we changed the locator path to locate play button
//After typing WebUI.clickImage in the below step, you can just drag and drop image from Repository.
WebUI.clickImage(findTestObject('Object Repository/Page_Images/PlaygameButton'),FailureHandling.STOP_ON_FAILURE)

Thread.sleep(3000)
//Click on the info button - Observe that we changed the locator path to locate info button
WebUI.clickImage(findTestObject('Object Repository/Page_Images/info'), FailureHandling.STOP_ON_FAILURE)

Thread.sleep(3000)
// Click on the Forward button three times
for(def index: (1..3)) 
{
  WebUI.clickImage(findTestObject('Object Repository/Page_Polar Tale/Forward'), FailureHandling.STOP_ON_FAILURE)
}
Thread.sleep(3000)

WebUI.closeBrowser()

13) Now Save and Execute the above script and observe that Automation Script created in Katalon Studio will run successfully by clicking all the buttons using image locators mentioned.

Next Steps:

  • > To learn more about Automating Games using Katalon Studio, continue to the next post (Click on Next Post Link Below)
  • > Check complete Katalon Studio Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Rama Sharma

I am Rama Sharma. Currently working as Game Tester at Ingenuity Gaming.

Connect to me on Linked In (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

<<Complete Tutorial>>       Next Post>>

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp