Xpath bug: Cannot read property 'toUpperCase' of undefined

Hi,
I have seen similar posts but this xpath issue has not been addressed yet.

  1. It seems using comment() or text() (e.g. xpath=(//*[@class=‘account-title’])/text()[2] ) in xpath will return the error “Cannot read property ‘toUpperCase’ of undefined” when actually the element was found.

  2. If element was not found it turns the regular error message: “timeout reached when looking for element” which is correct

I do suspect that Kantu in the background is compiling xpath somehow using javascript engine because googling the error message “Cannot read property ‘toUpperCase’ of undefined” leads to javascript errors reports.

This is my html code trying to use the xpath comment xpath=(//*[@class=‘account-title’])/text()[2]

<span>
@class="account-title"
@ng-if="vm.account"
@style=""
Text1
<!-- -->
<i>
@ng-if="vm.data.hasDataSyncStatusIssues"
@tabindex="0"
</i>
<!-- -->
Text2 I try to get
<!-- -->
<span>

Do you have a test macro for me that I can run?

The Kantu command would be like this (but you need a web page that has the code similar as shown above to test):

{
“Command”: “storeText”,
“Target”: “xpath=(//*[@class=‘account-title’])/text()[2]”,
“Value”: “myVar”
},

Do you also have a test website for me? :wink:

Yes I just found one ;):
Open storeText - Selenium IDE Commands Tutorial
and try

{
      "Command": "storeText",
      "Target": "xpath=(//*[@id='header'])/text()[1]",
      "Value": "myVar"
    },

returns:
[error][ignored]
Line 4: Cannot read property ‘toUpperCase’ of undefined

same as for:

{
      "Command": "storeText",
      "Target": "xpath=(//*[@id='header'])/comment()[1]",
      "Value": "varAccountName"
    },

Thanks for the test case!

HI, It has been a little while, I’m just just curious, did you find out what is triggering this issue?

It was a classic bug :slight_smile: => It will be fixed in the next update.

Yeah :slight_smile:

Thank you

Bug fixed in V5.8.8 - thank you for reporting it!