1

I'm crawling a card that not always have an SVG, but when it does I need to know that. I need to check whether an SVG exists inside a card. Here's what I have by now (that doesn't work):

jog = browser.find_elements_by_xpath("//div[@class='cartola-atletas__card cartola-atletas__card--com-parciais']")[k]
                    
if jog.find_element_by_xpath("./svg[@class='cartola-atleta-simples-capitao-label']").is_displayed():
     capitao = 'SIM'

This code never gets inside the if statement, even when its condition evaluates to true.

Here's the code I'm crawling:

<div class="cartola-atletas__card cartola-atletas__card--com-parciais">
     .
     .
     .
     <svg class="cartola-atleta-simples-capitao-label">
     .
     .
     .
</div>

What am I doing wrong?

  • 3
    You can't get `svg` elements like that. see workaround using `name()`: https://stackoverflow.com/a/57076106/8375783 – Trapli Feb 03 '21 at 00:13

0 Answers0