gpt4 book ai didi

jquery - 对于私有(private)列表 正确定义 following-sibling

转载 作者:行者123 更新时间:2023-11-28 02:15:59 26 4
gpt4 key购买 nike

我正在使用 following-sibling 为 webelement 的私有(private)列表创建 Xpath。我尝试用主页上的产品创建一个列表:http://automationpractice.com/index.php

对于以下 Xpath,它不遵循产品列表:

xpath="//ul[contains (@class, 'product_list grid row homefeatured')]/following-sibling:: li"

如何为列表网络元素创建正确的 Xpath?

脚本:

<ul id="home-page-tabs" class="nav nav-tabs clearfix">
<div class="tab-content">
<!-- Products list -->
<ul id="homefeatured" class="product_list grid row homefeatured tab-pane active">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 first-in-line first-item-of-tablet-line first-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 last-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 last-item-of-tablet-line first-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 last-in-line first-item-of-tablet-line last-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 first-in-line last-line first-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 last-line last-item-of-tablet-line last-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
<li class="ajax_block_product col-xs-12 col-sm-4 col-md-3 last-line first-item-of-tablet-line first-item-of-mobile-line last-mobile-line" style="height: auto; margin-bottom: 0px;">
</ul>
<!-- Products list -->

Screeenshot

最佳答案

我认为对于给定的 url,包含 product_list grid row homefeatured 的类属性没有 following-siblingsli。从那一点开始的下一个 sibling 将是下一个 ul

也许您正在寻找:

//ul[contains(@class, 'product_list grid row homefeatured')]/li

要从 ul 中获取所有列表项,您可以使用例如:

//ul[contains(@class, 'product_list grid row')]/li

关于jquery - 对于私有(private)列表 <webelement> 正确定义 following-sibling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48478158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com