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
  • Simple wildcard searches for pattern matching (2)
    • Don Pedro: For that scenario it seems .contains would be your choice. For example, variable.contains(‘amazo n.com’) to see if the url had amazon.com. In that case, www.amazon.com, forum.amazon.com, retail.amazon.com would all...
    • Jony: Hi, How can I use a wild card to assert a URL is the one I want. I just want to verify the domain ==expected but not anything after it. Tried * but not working and only works when I have full URL.
  • Create a Dynamic Object at Runtime (2)
    • Saish: How to add shadow root parent to this runtime object..
    • Jeremy Brien: I appreciate this! I saw this post on LinkedIn this morning and was able to find a use case for it! I found that defining my xpath with an iterable variable allows me to loop through and capture text from tables created...
  • Output status messages and test information by writing to the Log File Viewer in Katalon Studio (2)
    • Don Pedro: That would be things like: log.logWarning(‘The import date listed on the site is: ‘ + importDate) log.logWarning(‘The value from the site is: ‘ + salesFigure) log.logWarning(‘Filter Results for ‘ +...
    • Prashant Pednekar: Thanks for the informative article but can we also put some variable values to make it more exciting.
  • Setting up a repeatable Search Method in Katalon Studio (1)
    • RJ: Thanks a lot! This is very helpful 🙂
  • Filling forms with random numbers in Katalon Studio (3)
    • Patrick Clough: We created a handy random string generator custom keyword. The method takes in a string for the type of string you want, and an integer for the length. Looks like this: static String RANDOM_ALPHANUM =...
    • 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
  • 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.