2016-08-04 41 views
-4

enter image description here請幫我解決這個問題。參考上面的圖片。獲取HTML中的屬性值

+3

而不是屏幕截圖需要在這裏分享您的代碼..並指定您的編程語言以及.. –

+0

可能重複的[如何獲得webdriver中的div內的屬性值](http://stackoverflow.com/questions/ 17592786 /如何對獲得屬性 - 值內-A-DIV-在-的webdriver) – JeffC

回答

2
WebElement element = driver.findElement(By.id("mod-sellerRating-9")); 
String dataSellerRating = element.getAttribute("data-sellerrating"); 

如上所述,我會用By.id而非By.xpath