Probleme accessing Test Objects in frames from code


I am using Katalon Studio 7.2.1 to record and test a web application where all the content is within two cascading frames.
I have no problem to record and replay test cases using Object Repository until I need to manipulate the test objects from code (custom keywords).

From code, it always fails to access objets that are inside frames with the following error :

Unable to find the element located by ‘By.xpath: //input[@name=‘textinput1’]’ (…)


You will find attached a few html pages and my Katalon project to reproduce the problem. (35.7 KB)

When I test the same form without surrounding frames, the same code works fine.
But I can’t test without frames in the real application.


Should I add some code to ensure that frames are well managed from the following code ?
I would like to be able to use the same recorded objects from the “visual” test cases and code.

def AccessElementFromCode(TestObject to) {
	try {
		WebElement element = WebUiBuiltInKeywords.findWebElement(to);
		KeywordUtil.logInfo("element is of type " + element.getTagName());
	} catch (WebElementNotFoundException e) {
		KeywordUtil.markFailed("Element not found");
	} catch (Exception e) {
		KeywordUtil.markFailed("Fail to click on element");


Thanks !

Your problem is that your ‘right’ frame is inside the ‘global’ frame. There are multiple ways around this. Either make it that your “frame right” testobject has parent the “frame global” and you can use the testobjects.
However, since you are combining TestObjects with WebElements (in the keyword), it’s better to:

  1. Set parent of frame_right to frame_global
  2. Do NOT set the parent of the input field
  3. Use “WebUI.switchToFrame(findTestObject(‘Framed Content/frame_right’), 1)” before you are calling functions that need to be executed within the frame.

Best option: don’t use frames, they are so 20th century :slight_smile: