Q:

Python Selenium - Next line delimited issue

This is HTML:
<h1>
        Sample Test
    </h1>

I need to use = to find the text on the page.
What will be the easiest way to fix this XPATH, so it will work:
browser.find_elements_by_xpath('//h1[text()="Sample Test"]')

Please do not suggest to use /n as part of the "Sample Test" string

A:

Use the following xpath using normalize-space()
browser.find_element_by_xpath('//h1[normalize-space(text())="Sample Test"]')

OR
browser.find_element_by_xpath('//h1[normalize-space(.)="Sample Test"]')

