Java 如何使用HP UFT或Selenium Webriver检索open Graph的元标记属性

Java 如何使用HP UFT或Selenium Webriver检索open Graph的元标记属性,java,selenium-webdriver,qtp,hp-uft,Java,Selenium Webdriver,Qtp,Hp Uft,我正在尝试验证我们站点中的opengraph元标记。以下是HTML代码: <div class="atg_store_applicationResourceContainer"> </div> <meta name="robots" content="index, follow" /> <!-- Coming inside regular metadetails-->

我正在尝试验证我们站点中的opengraph元标记。以下是HTML代码:

<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>

分段式客厅
var _adblock=true;
我试图从
meta
标记中获取
content
属性的值,该标记的
属性值为
og:title
&
og:description
。任何帮助都会有帮助

我能够找到带有名称的meta的内容,但无法获得
&
的内容,因为标记没有名称


我们同时使用UFT和seleniumwebdriver(Java)。因此,我可以在任何一个方面使用帮助。

对于Selenium,您可以使用xpath,如

//meta[@property='og:title']
//meta[@property='og:description']
要获取内容,请使用
WebElement

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

对于Selenium,可以使用xpath,如

//meta[@property='og:title']
//meta[@property='og:description']
要获取内容,请使用
WebElement

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