Reputation: 49
There is a webtable in which I need to select from 1st row only 2nd 3rd and 4th column. I have tried using AND operator to select multiple td but that xpath is not working.
Xpath for 1st row which works good
((//div[contains(@id,'ReportGridStyle_forRW')])[2]//tbody/tr)[2]
Xpath to select td 2nd works good
((//div[contains(@id,'ReportGridStyle_forRW')])[2]//tbody/tr)[2]//td[position()=2]
((//div[contains(@id,'ReportGridStyle_forRW')])[2]//tbody/tr)[2]//td[position()=2 and position()=3 and position()=4]
Upvotes: 1
Views: 2492
Reputation: 168082
If you really want to use XPath go for the following:
descendant
axe for traversing the table tag to locate the first tr elementposition()
function to limit the rows to "interesting" only:
//table/descendant::tr[1]/td[position() >= 2 and position() <= 4]
References:
Also be aware that you can use Table class from the Html Elements framework - it provide you a clear API for working with Tables.
Upvotes: 1