ฉันมี 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]"));
แต่ฉันได้รับข้อผิดพลาดต่อไปนี้:
Bad token, expected: ] got: .
xpath
โดยไม่มีmote.
เช่นเดียวกับ//tr[@id='12345']/td[1]
หรือไม่ - person Andersson   schedule 24.02.2016//tr[@mote\.id='12345']/td[1]
ใช้งานไม่ได้ใช่ไหม - person Andersson   schedule 24.02.2016GetAttribute
ของซีลีเนียมเพื่อกรองแถวจากภายในโค้ดของคุณได้ไหม ดังนั้นให้ทำDriver.FindElements(By.XPath("//table[@id='oTable']/tbody/tr"))
จากนั้นใช้ for loop เพื่อผ่านแต่ละรายการและลบอันที่ไม่มีแอตทริบิวต์ mote.id หรือไม่มีค่าที่ถูกต้องในแอตทริบิวต์ บางทีGetAttribute
อาจจะหละหลวมเกี่ยวกับจุดกึ่งกลางของแอตทริบิวต์มากกว่า XPath - person Ben C   schedule 24.02.2016<td>Status</td>
- person Mosam Mehta   schedule 24.02.2016