Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97762

python selenium says xpath expression is not valid

$
0
0

I was trying to exercise with selenium and I tried this:

phone = driver.find_element_by_xpath(("//table[@class='contact_info_table']/tbody/tr/td[contains(text(), r'\+[0-9]*']"))

in order to try to get the phone number that it's inside a table. The HTML of the table is the following:

<table class="contact_info_table">
<tbody>
    <tr>
        <th>......</th>
        <td>
            . . .
        </td>
    </tr>

    <tr>
        <th>......</th>
        <td>
            . . .
        </td>
    </tr>

    <tr>
        <th>Telefono:</th>
        <td><img style="vertical-align:middle; display: inline-block; margin-right: 10px;" src="../img/flags/it.png" title="Italia">+1234567890</td>
    </tr>

What I need to do is to get the 1234567 in the last tr. What am I doing wrong?

The error that I get is:

InvalidSelectorException: Message: Given xpath expression "//table[@class='contact_info_table']/tbody/tr/td[contains(text(), r'\+[0-9]*']]" is invalid: SyntaxError: The expression is not a legal expression.

Thank you.


Viewing all articles
Browse latest Browse all 97762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>