Parsing Strings in Katalon – Split, Substring and Readlines

Once text has been read from the page, it’s time to do something with it. In many cases, only a portion of the text is needed. For example, you may need the first part of a text string, or the last part. An example text string would be: (1/26/2018 – DAY 19 OF 22) The first thing is to read in the entire string into a variable: importDate = WebUI.getText(findTestObject(‘Page_/Sales Dashboard/mtd_Sales_Dashboard_Import_Date’)) Since I want the text to the left of the hyphen, I can use that in my split command. The [0] at the end indicates I want text to the left. If I change it to [1] it would be text to the right. parsedDate = (importDate.split(‘ – ‘)[0]) – returns (1/26/2018 parsedDate = (importDate.split(‘ – ‘)[1]) – returns DAY 19 OF 22) From there I can manipulate the text further for my needs. It’s also possible to break the line at the hyphen and return the resulting two […]

Clicking Buttons, Links and Drop downs in Katalon Studio

Along with entering and reading text, clicking on objects will make up many commands within a script. This includes clicking buttons, links, tabs and drop downs. There are multiple click style objects and several ways to define them. Some involve an XPATH notation, while others use a TAG and HREF notation. For example, to save a Prospect there is an Add button at the bottom of the form. When using the Katalon Recorder, the path to the button is defined as: //div[@id=’newProspects’]/button When defining that button as btn-Add New Prospect, the XPATH Equals //div[@id=’newProspects’]/button. The button can then be clicked using the following command. WebUI.click(findTestObject(‘Page_/Sales Plan Budget/New Prospect/btn-Add New Prospect’)) While most buttons will use an XPATH reference, links on the page may use the TAG and HREF to define them. For the site I’m working on, we have links for By Month, By Customer, By Category and the path looks like link=byCustomer. How does that translate into Katalon? It […]

Entering and reading text GetText, SetText and SendKeys in Katalon Studio

To get started with actual scripting, let’s look at two of the more commonly used functions, getting text from the website and putting text into a field or input box. From the Selenium IDE, these were referred to as storeText and type. StoreText is now GetText and Type is now SetText. There was also the SendKeys command, which is still available in Katalon. Going back to a previous example, here is a small dashboard with sales figures. In this example, I have defined the first cell of the table with the XPATH reference and created an object called Daily Sales Figure Main Dashboard. In order to retrieve that first value and store it in a variable, I can use the following command: dailySalesFigure = WebUI.getText(findTestObject(‘Page_/Sales Dashboard/Daily Sales Figure Main Dashboard’)) The variable dailySalesFigure will take on the value $44,931 and will be defined as a String. Using our Inventory Search field example, I have the following item on the page: […]

Katalon Studio – Manual View – The start of a test script

To start a new script, click the down arrow next to the New button and select Test Case. After being prompted for a name, you’ll be placed in the Manual view, which should look somewhat similar to the Selenium IDE and helps to build the framework of a test. Click the Add button to get a list of the commonly used commands like Set Text, Get Text, Wait for Page Load, Delay, Click, etc. At first the list may not seem as extensive as the old IDE, but don’t worry, Katalon can do everything the old IDE did and plenty more. Clicking the Add button, offers the short list of commands, while clicking the down arrow next to Add presents other actions like Decision Making, Looping, Branching and Exception Handling. As an example, a standard test can start by navigating to a page, clicking an item, reading text, waiting for a page to load and verifying an element exists. The […]

Katalon Studio – Creating Objects

The first thing to understand with Katalon Studio is that it’s object oriented. That means that every item you want to interact with on the page should have an object created for it. For example, if you want to enter text on a form, that input field would be an object referencing the path to find it. If you want to click the OK or Submit button on a page, there should be an object with the path to the button. At first, that may seem like extra work and perhaps even a waste of time. But in the long run, it’s very beneficial. You have to reference the object anyway, but this method gives it a friendly name and again, if the path to the object changes, it only needs to be changed in one place. As an example, let’s say you wanted to enter text into a form. Here is an input field on a real Inventory Search […]