Search code examples
jquerycssgroovyweb-testingkatalon-studio

Katalon: Unable to click on object: Web element with id not found


I'm new to katalon so I might have simple questions. I'm trying a recording example. My purpose is just verify if an admin user is able to view the entire dashboard page by checking if admin-only elements are rendered. For ex, 'users' can be viewed only by admin, so the sidebar-menu should have users as one of the list elements and the users is a clickable link. In recording mode, all actions and behaviors are not throwing exceptions. When I saved the recording as a groovy test script and ran it again, it failed on click users menu navigation. The error stack is printed as follow:

Test Cases/Super_Admin_Access_Test FAILED because (of) Unable to click on object 'Object Repository/MyApp/a_users' (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/MyApp/a_users' located by 'By.xpath: //a[count(. | //[@class = 'users']) = count(//[@class = 'users'])][count(. | //[@href = '/Accounts/Users']) = count(//[@href = '/Accounts/Users'])][count(. | id("nav-accordion")/li[@class="sub-menu"]/a[@class="users"]) = count(id("nav-accordion")/li[@class="sub-menu"]/a[@class="users"])]' not found


Solution

  • The Xpath generated by recorder is not in a valid syntax, you can use spy web utility to verify if the xpath generated by auto detector is true or not. Katalon also provide you the options to manually input the element xpath or css, this will ensure that you got the correct DOM element you want to test.