I have made a project on GitHub, where you can reproduce the insident.
OS: Mac OS 10.13.6 High Siearra
Katalon Studio: version 5.7.1
How to reporoduce the insident
- git clone this project or download ZIP form the relases page.
- open the project with Katalon Studio v5.7.0 or higher.
- open Test Caset/TC1 and execute it. The source is as follows:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser('')
WebUI.navigateToUrl('http://www.angularjshub.com/examples/forms/textinputs/')
WebUI.verifyElementPresent(findTestObject('Object Repository/Page_AngularJS Hub Text Inputs/iframe_Example_exampleIFrame'), 10)
WebUI.closeBrowser()
The test case will fail with the following message:
java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null
What is expected
The test case should pass.
What Actually occurs
The test case fails.
Unable to verify object 'Object Repository/Page_AngularJS Hub Text Inputs/iframe_Example_exampleIFrame' is present
(Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.)
My investigation
The Test Object âObject Repository/Page_AngularJS Hub Text Inputs/iframe_Example_exampleIFrameâ was generated by the Spy Web. It has Selection Method: XPath
, and it seems to have a valid Selector: //iframe[@id='exampleIFrame']
.
But the message is saying that *âthe XPath is nullâ. This is the point I am curious about.
I did 2 experiments.
manually turned to Selector: Attributes
I changed manually the Test Object to have Selection Method: Attributes
and set Selector by tag and id: //iframe[@id = 'exampleIFrame']
.
When I ran the Test Cases/TC1
, it PASSED.
manually turned back to Selector: XPath
After this fist experiment, I changed mannually the Test Object to have Selection Method: XPath
. It got a valid selector: //iframe[@id='exampleIFrame']
. This is just the same as the one generated by Spy Web. When I ran the Test Cases/TC1
, it PASSED.
Once passed, the Test Cases/TC1
will PASS forever. The only way to make it FAIL again is to clone the project from the GitHub repository and start fron scratch.
Conclusion
I believe there is a small bug in Katalon Studion 5.7.
I believe that the message âCannot find elements when XPath expression is nullâ started appearing since 5.7.0 which changed the specificaiton of Test Object: Selection method â XPath, Attributes, CSS
I think that the Test Object was generated by Spy Web in a internal state somewhat incomplete, which caused the message Cannot find elements when XPath expression is null comes up. I manually edited the Test Object â this operation seems to change the internal state, and hides the problem.
I guess that upgrading old version Katalon Studio to newer version (>=5.7.0) causes similar problem.
In the Katalon Forum I have seen a few posts reporting the same message.
- org.openqa.selenium.InvalidSelectorException - #4 by kazurayam - Bugs Report - Katalon Community
- http://forum.katalon.com/discussion/10198/set-text-for-a--element--in-a-frame-reportcannot-find-elements-when-the-xpath-expression-is-null
- http://forum.katalon.com/discussion/10027/web-recorder-unable-to-go-into-an-iframe-object-to-enter-the-data-for-notes-web-studio-571