problem with selector with space, selenium python

0

I have a problem with the selectorer, which has a space at the beginning:

I have something like this on html:

    <div class=" _xyz"></div>

and in python I do this:

    driver.find_elements_by_class_name(' _xyz')

or this other:

    driver.find_elements_by_class_name(' _xyz')

The result is selenium saying that it does not locate the element. How do I select elements that have a space at the beginning?

    
asked by Rolando Ruben Franco 16.06.2018 в 20:15
source

1 answer

1

Normally spaces are not a problem for selectors. Alternatively you could try to use a search by xpath with the function normalize_spaces

driver.find_elements_by_xpath(".//div[normalize-space(@class)='_xyz']")
    
answered by 18.06.2018 / 08:15
source