2016-07-12 13 views
0

Ich versuche, das offene Grafik-Meta-Tag & in unserer Website zu überprüfen. Hier ist der HTML-Code:Abrufen der Meta-Tag-Eigenschaft Für offene Grafik mit HP UFT oder Selen 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> 

Ich versuche, den Wert des content Attributs von meta-Tags zu erhalten, die den property Attributwert als og:title & og:description. Jede Hilfe wäre hilfreich.

ich in der Lage bin zu finden, den Inhalt der Meta mit Namen zu bekommen, aber ich bin nicht in der Lage, den Inhalt <og:title> & <og:description> zu erhalten, da der Tag hat keinen Namen

Wir verwenden beide UFT & Selen WebDriver (Java). So kann ich Hilfe bei jedem einzelnen verwenden.

Antwort

2

Für Selen können Sie mit XPath wie

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

gehen und den Inhalt verwenden getAttribute() Methode der WebElement

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

Vielen Dank für Ihre Hilfe. Es funktionierte – Rohit