Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
11511 มุมมอง

Watching this sample code, how to xpath pointing to the second element called "example_a"?:

<span class="example_a"/>
<span class="example_b"/>
<span class="example_a"/>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Roberto,

If you'd gave all classes an unique name you could do the following:

<xpath expr="//span[@class='example_a']>
    <!-- Some code here -->
</xpath>
But, since this is not the case, you should just use an index. For example:

<xpath expr="//span[3]">
    <!-- Some code here -->
</xpath>
This will search the third element that is a span. This code literally says 'get me the third item that is a span'.
Yenthe
อวตาร
ละทิ้ง
ผู้เขียน

Thank you very much for your answer.

No problem, best of luck with Odoo!

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 20
3681
1
ส.ค. 19
6354
1
ต.ค. 16
6496
1
ก.พ. 25
2531
3
ธ.ค. 24
2216