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
  • How To Disable the Quicken Registration Prompt (24)
    • Joe SR>: My monthly income is deposited into my Credit Union account. I use debit whenever possible. I write checks manually and mail them. I use Quicken 2012 off-line only. I have entered all my money and investment accounts. I...
    • Prtet: Never say never….every time I swear I will never use Quicken again, I discover that there are still no viable alternatives. Amazing that there is no decent personal finance software.
    • Joe D.: Holding CTRL + Shift keys and selecting On Line | One Step Update from the main menu worked for my Quicken 2004. I’m grateful that you wrote a synopsis (“Simply put, …”) just beneath the link to the blog...
    • Susan Long: I bought my quicken disc in the beginning and it came with a registration number. I rang the helpline and they gave me the code to put in and talked me through it. It you downloaded your version then you don’t own it...
    • Peter: You might consider running your old version of Quicken on an ancient computer. This is what I have done for years. The newer versions are fraught with problems- criminal, in my opinion. One version made mathmatical errors when...
    • Roslyn Chamberlain: Can I stop the countdown in quicken 2001 says only 8 sessions left. and what will happen after?
  • Parsing Strings in Katalon – Split, Substring and Readlines (1)
    • Ellen: Thanks for sharing!! I like your contributions to Katalon topics.
  • Working with Dates and Date Formatting in Katalon Studio (6)
    • Ajoo: Thank you for the details. How do i remove leading “0” from dates. i.e. while formatting i receive 04/21/2019, but i need 4/21/2019. (same applies for date)
  • What is Katalon Studio? A Distro of Selenium, Groovy and Eclipse (1)
    • Mahesh: Looking for more posts on katalon studio.your katalon stuffs are always exiting
  • 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 ‘ +...
  • Setting up a repeatable Search Method in Katalon Studio (1)
    • RJ: Thanks a lot! This is very helpful 🙂