我正在尝试选择包含锚点的元素,但文本被隐藏在div内部的段落中.这是我正在使用的HTML:
<a class="item" ng-href="#/catalog/90d9650a36988e5d0136988f03ab000f/category/DATABASE_SERVERS/service/90cefc7a42b3d4df0142b52466810026" href="#/catalog/90d9650a36988e5d0136988f03ab000f/category/DATABASE_SERVERS/service/90cefc7a42b3d4df0142b52466810026">
<div class="col-lg-2 col-sm-3 col-xs-4 item-list-image">
<img ng-src="csa/images/library/Service_Design.png" src="csa/images/library/Service_Design.png">
</div>
<div class="col-lg-8 col-sm-9 col-xs-8">
<div class="col-xs-12">
<p>
<strong class="ng-binding">Smoke Sequential</strong>
</p>
Run Code Online (Sandbox Code Playgroud)
我用来试图阻止它的代码是针对"Smoke Sequential"文本:
driver.findElement(By.linkText(service)).click();
Run Code Online (Sandbox Code Playgroud)
变量'service'在其中包含"Smoke Sequential".当我运行它时,我收到以下错误:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Smoke Sequential"}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.