How to get HTML5 data attribute using xpath? How to get HTML5 data attribute using xpath? ruby ruby

How to get HTML5 data attribute using xpath?


You get the table like this:

//span[@data-id='table1']/table

Select the data-id attribute and get the child element of name table.


Answering my own question...This appears to get the exact element.

driver.findElement(By.xpath("//*[@data-id='table1']"))


I think you can also use the cssSelector

driver.findElement(By.cssSelector("[data-id='table1']"));