使用selenium php服务器从类成员的第三个子级获取数据
我为这件事伤了一天的脑筋。我有html内容的层次结构,在页面中重复:使用selenium php服务器从类成员的第三个子级获取数据,php,selenium,Php,Selenium,我为这件事伤了一天的脑筋。我有html内容的层次结构,在页面中重复: <div class="layout-header"> <div> <a rel="ajax-href-view" href="https://www.dummy.com/view/d67617688d2b55"><img src="edit.png" title="edit Website.com Below Content 728x90" alt="edit"
<div class="layout-header">
<div>
<a rel="ajax-href-view" href="https://www.dummy.com/view/d67617688d2b55"><img src="edit.png" title="edit Website.com Below Content 728x90" alt="edit"></a>
<a rel="ajax-href-view" href="https://www.dummy.com/view/d9360769dd2b41"><span style="text-transform:uppercase;">Edit</span> Website.com Below Content 728x90</a>
</div>
</div>
我只是想看看我可以从这个类中获得一些内容,但是当我试图深入层次结构时,我完全迷失了方向。
在
布局标题
类元素上循环时,如何获取第一个
href和第二个
文本?或者,如果有任何其他方式我想听到它…thx您可以通过以下方式一次性获得:
这里我们得到了
a
元素,该元素具有span
with text=“Edit”,位于div
内,位于div
内,带有布局标题
类。您可以通过以下方法一次获得它:
这里我们得到了a
元素,它具有span
with text=“Edit”,位于div
内,位于div
内,带有布局标题
类
$attr = $this->webDriver->findElements(\WebDriverBy::className('layout-header'));
foreach ($attr as $key => $value) {
var_dump($value->getAttribute("style");
}
WebDriverBy::xpath('//div[@class="layout-header"]/div/a[span = "Edit"]')