0

fellows!

I'm trying to get a the text which is recognized in the developer tool of chrome, but once I run the test in Robot Framework I'm getting an error. The code used is:

${name}= Get Text xpath://tr[1]/td[1]/text()

Chrome dev tool

Robot Framework result

As a work around I did this:

    ${obj_name}=            Get Text  xpath://tr[1]/td[1]
    ${obj_name_fd}=         Get Text  xpath://tr[1]/td[1]/mat-icon
    ${obj_name}=            Replace String   ${obj_name}   ${obj_name_fd}   ${EMPTY}

I did get "xpath://tr[1]/td[1]" which returns all the text in it: "auto_async_blah_blah_blah".

Tha tag "td/" contains the tag "mat-icon/" with the text "file_download" and also the pure text "auto_async_blah_blah_blah" (without a tag... as [img][2]). So as a result I have:

"file_download auto_async_blah_blah_blah"

Then I get the "xpath://tr[1]/td[1]/mat-icon" and replace it for ${EMPTY}, in order to keep only "auto_async_blah_blah_blah".

1 Answers1

0

This xpath:

//tr[1]/td[1]/text()

would return a TextNode where as Selenium expects back a WebElement.


Solution

Modify your command as:

${name}=    Get Text  xpath://tr[1]/td[1]
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi, friend, thanks for your answer! I did get "xpath://tr[1]/td[1]" as a work around, but it returns all the text conteined in "//tr/td". Tha tag "td/" contains the tag "mat-icon" with the text "file_download" and also the pure text "auto_async_blah_blah_blah" (without tag). So I have "file_download auto_async_blah_blah_blah" Then I get the "xpath://tr[1]/td[1]/mat-icon" and replace it for ${EMPTY}, in order to keep just the "auto_async_blah_blah_blah". – Christian ReSa Mar 05 '23 at 17:43
  • @ChristianReSa So Selenium now recognizes the xpath element without `text()`. Glad to be able to help you. Feel free to raise a new question with your new requirement. – undetected Selenium Mar 05 '23 at 19:59