Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用xpath找到元素_C#_Xpath_Drop Down Menu - Fatal编程技术网

C# 无法使用xpath找到元素

C# 无法使用xpath找到元素,c#,xpath,drop-down-menu,C#,Xpath,Drop Down Menu,我无法使用xpath找到元素“Inventory”。我不确定我是否正确使用了它。我目前没有添加alt标记的权限 // C# IWebElement dropdown = driver.FindElement(By.XPath("//a[@class='dropdown-toggle']")); IWebElement inventory = dropdown.FindElement(By.XPath("//a[text()='Inventory'] /@href")); /

我无法使用xpath找到元素“Inventory”。我不确定我是否正确使用了它。我目前没有添加alt标记的权限

// C#
IWebElement dropdown = driver.FindElement(By.XPath("//a[@class='dropdown-toggle']"));
IWebElement inventory = dropdown.FindElement(By.XPath("//a[text()='Inventory']           /@href"));

//html
<li class="dropdown open">
   <a class="dropdown-toggle" data-toggle="dropdown">
           Inventory
           <i class="caret"></i>
   </a>
   <ul class="dropdown-menu">
          <li>
              <a href="/government/product-categories">Product Categories</a>
          </li>
   </ul>
</li>
/C#
IWebElement dropdown=driver.FindElement(By.XPath(“//a[@class='dropdown-toggle']);
IWebElement inventory=dropdown.FindElement(By.XPath(“//a[text()='inventory']/@href”);
//html

  • 术语“库存”周围有一些空白。用户
    包含(…)
    以执行子字符串搜索:

    //a[contains(., 'Inventory')]