Automating doesn't just involve navigating and clicking through links. It's useful for switching tabs, finding broken links, and even dragging and dropping. The passing of values to text fields is one of the most important aspects of test automation. By using the sendKeys() method, we'll learn how this helps us pass values to text fields.
The sendKeys() method in Katalon is used to enter editable text and password content during the execution of tests. Locators such as name, class, and id are used to identify these fields. A web element provides this method. The sendKeys() method does not replace existing text in any text box. sendKeys() can also be used to click the buttons automatically. sendKeys() provides the facility to simulate keystroke events on the specified element in software testing services.
Following are the steps for using Send Keys in Katalon:
- From the menu, select File → New → Keyword
- As a result, a new keyword is created in the package
- Click on the above file to open it
- Under the items column, enter a new 'Web UI Keyword'
- Click on 'Send Keys'
- Tap twice on the object column. The new model will appear with other columns
- Replace the value type 'String' with 'Keys'
- Tap twice on the column value. A second modal will appear, and the user can tap the keys directly to the keyboard or select it from the list
- When you're done, save the Keyword file
A simple example is WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.ENTER))