Using TypeIt4Me with Katalon Studio

In an previous article, I made comment of TypeIt4Me as a helpful tool to work alongside Katalon Studio. After several months, I have a full library of code snippets tucked away in TypeIt4Me, that allow me to put tests together much faster. In essence, I have automated parts of my automation code.

TypeIt4Me is a text expander that allows me to type a single keyword and have it converted to a block of code. In most demos you see, the example is to type in something like “ttyl” which converts to Talk to you later. Or an “addr” abbreviation gets converted to:

1313 Mockingbird Ln
Anywhere ST, 90210.

These are fine examples, but code snippets are just as valid and save a huge amount of time.

For example, I have the keyword replace@ set up as:

tempText=tempText.replaceAll("[\$,]", "")

I can also type in for@ and get:

for (loop = 1; loop <=10; loop++) {
  println(loop)
}

The amount of expanded text can be just about anything. I also have one for the “lorem ipsum” text. I type in lorem@ and I get:

Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Sed posuere consectetur est at lobortis. Etc, etc, etc, for another couple paragraphs.

It could also be more meaningful code like reading the contents of a table using the web driver code, as in this example:

readtable@

WebDriver driver = DriverFactory.getWebDriver()
WebElement Webtable=driver.findElement(By.id("sales_dash_table")); // Replace TableID with Actual Table ID or Xpath
//Get the number of rows in the table and turn it into a List
List<WebElement> TotalRowCount=Webtable.findElements(By.xpath("//*[@id='sales_dash_table']/tbody/tr"));
//Display the number of rows in the table for the given sales rep
log.logWarning("No. of Rows in the WebTable: "+TotalRowCount.size());
//Loop through the table and output the information to Log File
//Read columns 1-4, assign each to a variable, then output the result to the Log File
for (loop =1;loop<=TotalRowCount.size();loop++)
{
companyName= driver.findElement(By.xpath("//*[@id='sales_dash_table']/tbody/tr[" + (loop)+ "]/td[1]")).getText();
log.logWarning('Company Name:=' + companyName)
sales= driver.findElement(By.xpath("//*[@id='sales_dash_table']/tbody/tr[" + (loop)+ "]/td[2]")).getText();
log.logWarning('Sales Figure Amount:=' + sales)
gp= driver.findElement(By.xpath("//*[@id='sales_dash_table']/tbody/tr[" + (loop)+ "]/td[3]")).getText();
log.logWarning('Gross Profit:=' + gp)
margin= driver.findElement(By.xpath("//*[@id='sales_dash_table']/tbody/tr[" + (loop)+ "]/td[4]")).getText();
log.logWarning('Margin % :=' + margin)
}

This is exceptionally faster than copy/paste and even if these snippets don’t turn out to be ones I use every day, I have a library of examples all in one place. For many, the only thing I have to change is the variables.

If you notice, each keyword has the @ symbol at the end. This is something I chose to make sure the text isn’t expanded accidentally. It purposefully denotes in my mind that I am inserting text and is a simple keystroke to add.

The other benefit of an program like TypeIt4Me, is that it’s available system wide. Atom and other editors can store snippets just as easily, but TypeIt4Me is available in all apps. I can use it within Katalon, within Atom, within Textmate, within Jira, within Github and everywhere else I work.

Text expanders aren’t just for writing emails or expanding the odd abbreviation here and there. They can be extremely power and beneficial to write commonly used code fragments and as a repository of useful code. TypeIt4Me says I have saved over a dozen hours of typing using this method.

Update: Here is a screenshot of TypeIt4Me with a series of shortcuts used for Groovy. On the left is the keyword I type, followed by the @ to indicate it’s an expanded keyword and not regular text. On the right is the text that will be inserted.

Other articles of interest:

3 Responses to Using TypeIt4Me with Katalon Studio

  • Manual says:

    Hi Don,

    I like the idea of using the TypeIt4Me for scripting test code. Could you please share how I can create.
    I also like the idea of creating code templates to use with code editors.

    Thanks,
    Manual

  • Don Pedro says:

    Added a screenshot to show some examples of how I have shortcuts configured for Groovy code. TypeIt4Me supports groups, so you can create shortcuts related to Groovy, Selenium, and other topics to keep them organized. You can also turn them on and off, meaning you can have the same keyword defined multiple times with different text, then toggle the one you actually want to work with.

  • Manual says:

    That’s great thanks for sharing.

Leave a Reply

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

Recent Comments
  • Filling forms with random numbers in Katalon Studio (2)
    • Don Pedro: randomNumber is the variable that holds the result of generating a new random number. Depending on how things work on your site, you might need to convert the number to a String before it’s recognized correctly....
    • Seth: When you are setting up randomNumber is this a new keyword or a new variable? I am trying to randomly generate unique socials and can’t seem to connect my generator to my Set Text.
  • Working with Dates and Date Formatting in Katalon Studio (5)
    • Ann: THANK YOU ! That worked perfectly !
    • Don Pedro: import groovy.time.TimeCategory currentDate = new Date() println currentDate use( TimeCategory ) { after30Mins = currentDate + 30.minutes } println after30Mins https://stackoverflow.com/ques tions/21166927/incrementing...
    • ricky julianto nugroho: hay can u gave me an example for plus a hour in the time ? example : now is 15 pm i want to print 16 in the text thank you
    • Don Pedro: formattedDate=mydate.format(&# 8220;MMM”) – Nov formattedDate=mydate.format(&# 8220;MMMM”) – November
    • Ann: This was a huge help. Thank you ! Do you have something for capturing the month spelled out? and abreiveiated? Example November Nov Thanks !
  • Boostnote for Code Snippets (1)
    • Manual: Hi Don, Regarding the code snippets and examples that you have created. Is there any GitHub repo or something that can be shared? Thanks
  • Using TypeIt4Me with Katalon Studio (3)
    • Manual: That’s great thanks for sharing.
    • Don Pedro: Added a screenshot to show some examples of how I have shortcuts configured for Groovy code. TypeIt4Me supports groups, so you can create shortcuts related to Groovy, Selenium, and other topics to keep them organized. You can...
    • Manual: Hi Don, I like the idea of using the TypeIt4Me for scripting test code. Could you please share how I can create. I also like the idea of creating code templates to use with code editors. Thanks, Manual
  • Another success with Katalon Studio (2)
    • Don Pedro: Since Katalon is free, a very practical demonstration of what it can would be to create the code needed to fill in forms. That was one of my first tasks as Katalon could fill in a lengthy form in seconds versus the minute or...
  • How To Disable the Quicken Registration Prompt (18)
    • Susan Long: I have Quicken personal 2012 which I only use to enter and retrieve data. It suits my needs perfect. Now they have blocked my access and want me to re register. I don’t want to upgrade as it I am comfortable with this...
    • Stewart: I have been using Quicken 200 basic since it was introduced but I now have a new PC using windows 10 and can’t get rid of the registration prompt. I have tried the above control/shift trick but to no avail. Any ideas
  • Conditional Statements – IF .. ELSE IF in Katalon Studio (1)
    • Allyson: I used this : elementVisible=WebUI.verifyEle mentPresent… but it failed because “FAILED because (of) Unable to verify object ‘Object Repository/Homepage/b_vaolopho c’ is present (Root cause:...