2016-07-12 5 views
0

본 사이트에서 열린 그래프 메타 태그 &을 확인하려고합니다. 내가 og:title & og:descriptionproperty 속성 값을 갖는 meta 태그에서 content 속성의 값을 얻기 위해 노력하고메타 태그 속성을 검색하는 방법 HP UFT 또는 Selenium Webriver를 사용하는 열린 그래프의 경우

<div class="atg_store_applicationResourceContainer"> 
      </div> 
     <meta name="robots" content="index, follow" /> 

      <!-- Coming inside regular metadetails--> 
          <!-- contentKey = --> 

     <!-- SEOTagID - **** --> 
    <title>Sectional Living Rooms&nbsp;</title> 
       <meta name="description" content="Find Sectional Living Rooms&amp;nbsp; that will look great in your home and complement the rest of your furniture." /> 
       <meta name="author" content="EXAMPLE.com" /> 

     <meta name="google-site-verification" content="UscxdOsY5bXX9hk_Y0GILMPvzsL66vDcHHwkZZ7Gxpg" /> 

     <meta property="og:title" content="Sectional Living Rooms&nbsp;"/> 
     <meta property="og:site_name" content="EXAMPLE"/> 
      <!-- requestSocialUrl = http://www.example.com/cartridges/PageSlot/PageSlot.jsp --> 
     <!-- customCanonical = http://www.example.com/furniture/Living-Rooms/Sectional-Living-Rooms/_/N-8wh --> 
         <link rel="canonical" href="http://www.example.com/furniture/Living-Rooms/Sectional-Living-Rooms/_/N-8wh" /> <!-- add + instead of space in words for SEO --> 
           <meta property="og:image" content="http:/images/unavailable.gif?$PDP_Cart_Primary_150x150$" /> 
      <meta property="og:type" content="product"/> 
     <meta property="og:url" content="http://www.example.com/furniture/Living-Rooms/Sectional-Living-Rooms/_/N-8wh"/> 
     <meta property="og:description" content="Find Sectional Living Rooms&amp;nbsp; that will look great in your home and complement the rest of your furniture.&amp;nbsp;#iSofa #abc"/> 
    <script>var _adblock=true;</script> 

다음은 HTML 코드입니다. 어떤 도움이 도움이 될 것입니다. 내가 이름을 가진 메타의 콘텐츠를 찾을 수 모르지만, (태그 우리는 UFT & 셀레늄 Webdriver을 모두 사용하는 이름

을 가지고 있지 않는 한 <og:title> & <og:description>의 내용을 얻을 수 아니다

자바). 그래서 나는 어떤 하나의 도움을 사용할 수 있습니다.

답변

2

셀레늄 위해 당신은

//meta[@property='og:title'] 
//meta[@property='og:description'] 

처럼 XPath는 함께 갈 수 그리고 콘텐츠가 도움을 WebElement

WebElement titleEl=driver.findElement(By.xpath("//meta[@property='og:title']")); 
String titleContent = titleEl.getAttribute("content"); 
+0

감사의 getAttribute() 방법을 사용하여 얻을 수 있습니다. 효과가있다. – Rohit