Getting the text between two particular selectors

In a webpage, I want to get the text between two particular selectors. How to do this in robot Framework Language??

To explain in detail, I have to get a bunch of text that I want to extract. The text is in separate paragraphs and each paragraph has its own selector. So I tried to get it using a parent element but it contains a lot of unwanted text. So, is there a way to get the text between two locators?? If there is i can specify the starting element and the end element.

Suggestion: You may extract the whole paragraph and use the python code to attain your extraction between texts.

Also, the python code you can use the chatgpt to help you :smile:

Thank’s for your suggestion.
Let’s consider this website.

In here, I want the text from Chapter 1 to the end of Chapter 2, but when I locate it and get the text, it gives me a whole bunch of unnecessary text at the start and the end. Can this be done using your solution?? I’m not sure and asking for assistance.

Hi, I am not sure I have understood your question correctly, but is this of any help?

# ${string} starts as "Hero Of Hearts Novel Chapter 01 - 02 | XH Tales"
${string}    Set variable        Hero Of Hearts Novel Chapter 01 - 02 | XH Tales
${string}    Fetch from left     ${string}    |
${string}    Get substring       ${string}    0    -1    # remove trailing space
${string}    Fetch from right    ${string}    Novel
${string}    Get substring       ${string}    1          # remove leading space
# ${string} now set to "Chapter 01 - 02"

Note ‘Strip string’ is a more elegant way to remove the leading and trailing space, however I included the above in case you needed more flexibility and control.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.