2014-09-22 14 views
8

का उपयोग कर वेब पेज से मेटा विवरण की सामग्री पुनर्प्राप्त करें वेबड्राइवर का उपयोग करके पृष्ठ के मेटा विवरण की सामग्री प्राप्त करना चाहते हैं।सेलेनियम वेबड्राइवर

Let, का कहना है कि डोम के नीचे से पाठ Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages

<script src="content/js/jquery.min.js"> 
<meta content="Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages." name="description"> 
<meta content="Test.com" name="keywords"> 

मैं

System.out.println(driver.findElement(By.xpath("//meta[@name='description']")).getText()); 

साथ करने की कोशिश की लेकिन कोड ऊपर मेरे लिए काम नहीं प्राप्त करना चाहते हैं।

उत्तर

10

आप एक विशेषता मान प्राप्त करने की कोशिश कर रहे हैं ताकि getText() उपयोग getAttribute() के बजाय:

driver.findElement(By.xpath("//meta[@name='description']")) 
     .getAttribute("content") 
संबंधित मुद्दे