Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium webdriver Xpath with dot (.) in attribute name

I have the following html:

<table id="oTable">
<tbody>
    <tr mote.id="12345">
        <td>Status</td>
        <td>1</td>
    </tr>
    <tr mote.id="54321">
        <td>Status</td>
        <td>2</td>
    </tr>
</tbody>

I want to locate the row with mote.id and click the first td-tag

WebElement element = getDriver().findElement(By.xpath("//tr[@mote.id='12345']/td[1]"));

But I get the following Error:

Bad token, expected: ] got: .
like image 976
Calle Avatar asked May 18 '26 23:05

Calle


1 Answers

To locate the <td> element, use :

WebElement element = getDriver().findElement(By.xpath("//td[contains(text(),'Status')]"));
like image 137
Mosam Mehta Avatar answered May 21 '26 02:05

Mosam Mehta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!