gpt4 book ai didi

html - 无法使用 XPath 按索引查找元素

转载 作者:行者123 更新时间:2023-12-01 05:38:47 25 4
gpt4 key购买 nike

<分区>

我在控制台中编写 XPath 来查找图标元素 $x("//mat-icon")。然后我得到元素列表:

0: <mat-icon class="mat-icon notranslate mat…-color ng-star-inserted" _ngcontent-cvb-c17="" aria-hidden="false" aria-label="start" role="img">
1: <mat-icon class="mat-icon notranslate mat…-color ng-star-inserted" _ngcontent-cvb-c17="" aria-hidden="false" aria-label="start" role="img">

我想选择第一个,所以我写了索引 $x("//mat-icon[1]") 但它不起作用。但是,如果我编写 $x("//mat-icon")[1] 它可以工作,但是当我在 IDE 中编写它时会出现错误消息:

driver.findElement(By.xpath("//mat-icon")[0]).click();

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