Unable to locate by Xpath in 5.4

When running some tests that worked fine on KS 5.3.1, now I get this error message:

Unable to verify if object ‘Object Repository/to’ is visible in viewport (Root cause: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression because of the following error:

SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘’ is not a valid XPath expression.

Can you show me your test object’s details?

Sure:

2018-04-17_10-29-18.png

Ah sorry to mention but can you help to post the full execution log of that log also, e.g in my case it’s working fine:

04-17-2018 03:30:05 PM - [START]  - Start action : click
04-17-2018 03:30:05 PM - [INFO]   - Finding Test Object with id 'Object Repository/Page_CuraHomepage/btn_MakeAppointment'
04-17-2018 03:30:05 PM - [INFO]   - Checking object
04-17-2018 03:30:05 PM - [INFO]   - Checking timeout
04-17-2018 03:30:05 PM - [INFO]   - Finding web element with id: 'Object Repository/Page_CuraHomepage/btn_MakeAppointment' located by 'By.xpath: //div[contains(text(), 'some text')]' in '30' second(s)
04-17-2018 03:30:36 PM - [INFO]   - Found web element with id: 'Object Repository/Page_CuraHomepage/btn_MakeAppointment' using heuristic method. Maching attributes: [id].
04-17-2018 03:30:36 PM - [INFO]   - Clicking on object: 'Object Repository/Page_CuraHomepage/btn_MakeAppointment'
04-17-2018 03:30:42 PM - [PASSED] - Object: 'Object Repository/Page_CuraHomepage/btn_MakeAppointment' is clicked on
04-17-2018 03:30:42 PM - [END]    - End action : click

04-17-2018 10:45:50 AM - [START] - Start action : click

04-17-2018 10:45:50 AM - [INFO] - Finding Test Object with id ‘Object Repository/Save’

04-17-2018 10:45:50 AM - [INFO] - Checking object

04-17-2018 10:45:50 AM - [INFO] - Checking timeout

04-17-2018 10:45:50 AM - [INFO] - Finding web element with id: ‘Object Repository/Save’ located by ‘By.cssSelector: button[data-target=“save”] .ui-button-text’ in ‘5’ second(s)

04-17-2018 10:45:50 AM - [INFO] - Found 1 web elements with id: ‘Object Repository/Save’ located by ‘By.cssSelector: button[data-target=“save”] .ui-button-text’ in ‘5’ second(s)

04-17-2018 10:45:50 AM - [INFO] - Clicking on object: ‘Object Repository/Save’

04-17-2018 10:45:50 AM - [PASSED] - Object: ‘Object Repository/Save’ is clicked on

04-17-2018 10:45:50 AM - [END] - End action : click

04-17-2018 10:45:50 AM - [START] - Start action : methods.custom.validationM

04-17-2018 10:45:50 AM - [INFO] - Finding Test Object with id ‘Object Repository/to’

04-17-2018 10:45:50 AM - [INFO] - Checking object

04-17-2018 10:45:50 AM - [INFO] - Checking timeout

04-17-2018 10:45:50 AM - [INFO] - Finding web element with id: ‘Object Repository/to’ located by 'By.xpath: //div[contains(text(), ‘some text’)] ’ in ‘1’ second(s)

04-17-2018 10:45:52 AM - [FAILED] - Unable to verify if object ‘Object Repository/to’ is visible in viewport (Root cause: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression because of the following error:

SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘’ is not a valid XPath expression.

(Session info: chrome=63.0.3239.132)

(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_102’

Driver info: com.kms.katalon.selenium.driver.CChromeDriver

Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528161 (5b82f2d2aae0ca…, userDataDir: C:\Users\…\AppData…}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 63.0.3239.132, webStorageEnabled: true}

Session ID: ed5fb84973e39e9c1c3dab1822d20c13

*** Element info: {Using=xpath, value=})

This still happens on v5.7:

Test Cases/TC-0030  FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to wait for object 'Object Repository/KUGLICA' to be visible (Root cause: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression  because of the following error:SyntaxError: Failed to execute 'evaluate' on 'Document': The string '' is not a valid XPath expression.  (Session info: headless chrome=67.0.3396.99)  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 0 millisecondsFor documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html

What is especially interesting is that the KUGLICA object in the Object Repository is defined by a CSS selector and I’m getting an xpath invalid selector error.

@Vinh Nguyen

This might be connected to chromedriver version. Does Katalon automatically change chromedriver version to 2.35 when updating version?

Because I updated Chromedriver to 2.41 a few days before updating Katalon Studio to 5.7.0.

Mate Mrse said:

@Vinh Nguyen

This might be connected to chromedriver version. Does Katalon automatically change chromedriver version to 2.35 when updating version?

Because I updated Chromedriver to 2.41 a few days before updating Katalon Studio to 5.7.0.

Obviously, I forgot to add: “and now it is back to 2.35”.

UPDATE:
It happens with Chromedriver 2.41, too.

@Katalon Studio, @Vinh Nguyen

Please, do something about this. My tests that used to run just fine are now failing!

Did you find a solution?
Having a similar error… but in the first run of my loop the element could be found by the xPath, in the second loop the exact same element has a invalid xPath, however it worked a few seconds before?

I’m am running 5.7.0. Tests suite was designed with 5.6.x. Is there a back-compatibilty issue ? It seems to be linkd to SELENIUM-Browser version. Some testcases worked few days ago. I had to re-design some tests step as a workaround. What a mess ;=(