OS
Windows 7
Katalon Studio Version
5.4.2
## Katalon Studio logs:
attached, but not relevant I think
## Environment (for Web testing)
Firefox 60.0.2
## Steps to reproduce -
I made a testbed html at Discussion #7609
The page contains following markup:
<table id="data" class="table">
<tbody>
<tr><td>ИВАН</td><td> ИВАНОВ ИВАН 123 </td></tr>
<tr><td>IVAN</td><td> IVANOV IVAN 123 </td></tr>
</tbody>
</table>
I made 2 Test Object:
(1) ‘Page_Discussion 7609/td_Latin_alphabet - text equals’
This Test Object is assigned with Basic method, which includes a factor of text/equals/IVAN. Screenshot is attached below:
(2) Page_Discussion 7609/td_Latin_alphabet - text matches
This Test Object is assigned with Basic Method, which includes a factor of text/matches regex/IVAN. Screenshot is attached below:
I made a test case named “TC1”. The code is as follows:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser('')
WebUI.setViewPortSize(703, 347)
WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/7609_testbed.html')
WebUI.verifyElementPresent(findTestObject( 'Page_Discussion 7609/td_Latin_alphabet - text equals'),
20, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.verifyElementPresent(findTestObject( 'Page_Discussion 7609/td_Latin_alphabet - text matches'),
3, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.closeBrowser()
## Expected Behavior -
I expected that both Test Objects success to match the HTML element
<td>IVAN</td>
## Actual Behavior -
when I ran the test case I got the following output in the log
...
[INFO] - Finding web element with id: 'Object Repository/Page_Discussion 7609/td_Latin_alphabet - text equals' located by 'By.xpath: //td[(text() = 'IVAN' or . = 'IVAN')]' in '20' second(s)
[INFO] - Found 1 web elements with id: 'Object Repository/Page_Discussion 7609/td_Latin_alphabet - text equals' located by 'By.xpath: //td[(text() = 'IVAN' or . = 'IVAN')]' in '20' second(s)
[PASSED] - Object 'Object Repository/Page_Discussion 7609/td_Latin_alphabet - text equals' is present
...
[INFO] - Finding web element with id: 'Object Repository/Page_Discussion 7609/td_Latin_alphabet - text matches' located by 'By.xpath: //td[(matches(text(), 'IVAN') or matches(., 'IVAN'))]' in '3' second(s)
[FAILED] - com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/Page_Discussion 7609/td_Latin_alphabet - text matches' located by 'By.xpath: //td[(matches(text(), 'IVAN') or matches(., 'IVAN'))]' not found
...
In other words, the following org.openqa.selenium.By.xpath(String) call succeeded:
By.xpath: //td[(text() = 'IVAN' or . = 'IVAN')]
but the following By.xpath() call failed
By.xpath: //td[(matches(text(), 'IVAN') or matches(., 'IVAN'))]
I have made a demo in the GitHub:
# Cause of failure
I think By.xpath() call with expression containing matches() function would NEVER work.
The matches() function was defined in XPath 2.0.
https://www.w3.org/TR/xquery-operators/#func-matches
Most of the existing xpath engines in the world supports XPath1.0 but not XPath2.0
As the following post tells, the Selenium WebDriver’s By.xpath implements XPath1.0, but lacks XPath2.0 support including matches() function.
How are XPath1.0 and XPath2.0 different? — see jaxen - FAQ / Which version of XPath does jaxen support? Does jaxen support XPath 2? section.
I suppose all of Test Objects in Katalon Studio with Condition “matches regex” will not work properly.
# My proposal
Katalon team should consider removing the Condition “matches regex” completely.