我一直在尋找一個XPath代碼來獲取HTML元素屬性的值作爲我的迴歸測試的一部分。任何人都可以請幫助在硒中使用xpath獲取屬性
的屬性值是每下一個webelement
下面動態變化中的HTML代碼
<figcaption id="recentVideosvideoname0" data-videono="xZA6FJ32Twe2GQYEuBHJnQ==" title="test for test" class="caption">test for test</figcaption>
我想屬性:data-videono
我已經試過這樣的事情
By.xpath(("//div[contains(@id,'recentVideos')]/div/a/figure/figcaption"));
請在發佈問題之前搜索論壇和谷歌。搜索如何使用硒獲取屬性會給你提供大量的信息。 –
您好Gaurang:我搜索沒有得到答案:( –
可能重複[如何使用XPath獲取屬性的值](https://stackoverflow.com/questions/23394828/how-to-get-the -value-of-an-attribute-using-xpath) –