Reading Text from a Disabled Input Field in Katalon Studio

Reading text from a disabled input field is a very specific example, but it took a lot of searching to get the right command. I figured it could be a time saver if I put up a working example. The table I’m working with looks like this: As noted, I want to read the Plan value, but it’s disabled at the moment so a standard GetText doesn’t read the value. This is a dynamic table, so I’m using the WebDriver to manipulate it. Once the import commands are in place, I can use the “getAttribute(“value”) to read the text from this input field. //Read text from an input field where the text is disabled plan = driver.findElement(By.xpath(‘//*[@id=\’customersTable\’]/tbody/tr[1]/td[7]/input’)).getAttribute(“value”) Again, I’m using the wildcard //* to find my customersTable. I then reference the “input” field and use the getAttribute. From there, I’m able to read $159,112 from the field. After that, it’s the standard commands to replace the $ and write it […]

Working with Tables using the Selenium WebDriver and Katalon Studio

While Katalon is capable of reading a table through an object declaration, it’s possible to do the same using the “Webdriver”, “List” and “findElement” commands. I use this method to count the number of rows in a dynamically generated table. It would be equivalent to the storeXPathCount from the Selenium IDE. Many of the tables I work with are static, meaning the number of rows doesn’t change. For example, we have a table for months, that’s always 12. We have a table for categories, that’s always 10. However, we have a table for customers, and that’s always different. I have a couple of tests where I need to know the number of customers in that table. To find out, I use the Webdriver to create a List of table rows, then get the Size of that List. I’ve also used this method when working with Contacts. We don’t display a count for the number of Contacts, but I can use […]

Wait For Alert, Verify Alert Present in Katalon Studio

We’ve looked at waiting for an element to appear, so now we’ll look at waiting for a an alert to appear. For the site I’m working with, there are two alerts to check for. The first is a confirmation that the Prospect has been created correctly and appears every time the Prospect details are Saved. The second is a warning dialog that presents when there is an error retrieving results. This is a search/query error and indicates a data error. For most search types this will not appear, but when it does, it means something is wrong. Katalon has two commands to handle both of these: WebUI.waitForAlert WebUI.verifyAlertPresent In most cases, either command will be followed by an: WebUI.acceptAlert() Which clicks OK for the dialog and continues executing code. For my tests, I have mainly used waitForAlert. For the first scenario, I wait for the alert because I know it’s coming. For the second, I check to see if it […]

Waiting for Elements to appear in Katalon Studio

As tests are running, there is a frequent need to pause the code execution to wait for an item to be available on the page. There might be a pause due to network speed or waiting for the results of a query. While it’s possible to use the Delay command, it might be better to use the WaitForElementVisible command. This waits for the specific element you want to interact with to appear on the page before the test continues. For one of my tests, I need to wait for the number of results to be returned before moving on. I could wait for the page, but I specifically need this number, and this text doesn’t appear until the query has completed. //Wait for the Results Found text to appear. This contains the number of Prospects on the page. WebUI.waitForElementVisible(findTestObject(‘Page_/Prospect Page Objects/label-Prospect Results Found’), 10) The code above waits for the label to appear, then my test can continue, which is […]

New Libraries to Import into Katalon Studio

Up to this point, we have added several new import statements to our projects. One was to use SendKeys, another for writing to the log file and another to mark a test as Failed or in Error. There’s also a few more coming as we get into using the WebDriver, so to keep things up to date, here is a list of import statements to add to your project. import internal.GlobalVariable as GlobalVariable //This section is needed to call the Selenium WebDriver import org.openqa.selenium.WebDriver as WebDriver import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory import org.openqa.selenium.By as By import org.openqa.selenium.WebElement as WebElement import com.kms.katalon.core.annotation.Keyword //This allows for the use of MarkFailed and MarkError import com.kms.katalon.core.util.KeywordUtil //This is for SendKeys import org.openqa.selenium.Keys as Keys //This is to write to the log file import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger KeywordLogger log = new KeywordLogger()