Get N-th element when there are multiple (and same) siblings. It also clears the previous value of the input field. In our case, for contains method, you provide a result of text() method as a haystack and substring as a needle.Ħ. WebUI Set Text Description Set the value of an input field, as though you type it in. small**You may see that in the first option, you have to specify exact text, whereas, in the second option, it is enough to provide only a substring. Text() returns a text of current node, contains() returns true/false based on parameters.Example: XPath offers several functions, but probably most used for test automation are text() and contains(haystack, needle) methods. when the same image is used on multiple places, but alt attribute is different. **This may be useful when a single attribute may not be sufficient to identify an element, i.e. Use XPath operator and to get element by multiple " and logo"] So relative Xpath approach can be easily applied.Ĥ. Then, use relative Xpath to locate your p does not have any unique ID, but its nearest ancestor (parent element) has. If unique identifier is not present, find nearest ancestor/descendant with unique identifier. Prefer using direct XPath (when unique identifier is id is (should be) unique within a page, so you may be sure that you are about to use correct element.ģ. If possible, keep your XPaths easy and short. This example does not look so bad, BUT – in feature-rich websites, you may have 15-20 elements between the root element and your object.Ģ. Select Menu File -> New -> Test Data (Katalon studio will show New Test Data Dialog.
In this article will see how to use excel sheet in KATALON studio by using findTestData method. For Data driven test cases we need excel sheet. Sample absolute Xpath in our sample code: It it very easy to get data from excel using Katalon Studio.
It works, but it is really hard to maintain – even the smallest change in page's source code can make Xpath invalid. Use this only and only when there is no other choice. The very best and ultimate practice is to avoid using absolute Xpaths.
mod Modulus (division remainder) 5 mod 2.// Selects nodes in the document from the current node that matches the selection no matter where they are.nodename Selects all nodes with the name "nodename".Click me Option 1 Option 2 Option 3 All rights reserved. click ( findTestObject ( 'Page_Login/btn_Login' )) 'Close browser' WebUI. setText ( findTestObject ( 'Page_Login/txt_Password' ), Password ) 'Click on \'Login\' button' WebUI. setText ( findTestObject ( 'Page_Login/txt_UserName' ), Username ) 'Input password' WebUI. findTestObject import .checkpoint.Checkpoint as Checkpoint import .checkpoint.CheckpointFactory as CheckpointFactory import. as MobileBuiltInKeywords import. as Mobile import .model.FailureHandling as FailureHandling import .testcase.TestCase as TestCase import .testcase.TestCaseFactory as TestCaseFactory import .testdata.TestData as TestData import .testdata.TestDataFactory as TestDataFactory import .testobject.ObjectRepository as ObjectRepository import .testobject.TestObject as TestObject import. as WSBuiltInKeywords import. as WS import. as WebUiBuiltInKeywords import. as WebUI import internal.GlobalVariable as GlobalVariable 'Open browser and navigate to AUT' WebUI.