ai didi

java - 如何在 Selenium Webdriver 的 xpath 中选择具有动态值的对象

转载 作者:行者123 更新时间:2023-12-01 13:37:06 24 4
gpt4 key购买 nike

你能帮我在 Selenium Webdriver 中选择一个 xpath 值是动态的对象吗? xpath 是

  dd.findElement(By.xpath("//*[@id='defaultSwatchContainer_wxnit']/div/div/ul/li[list]"))

这里“defaultSwatchContainer_”后面的“wxnit”随着每次页面加载而变化。谢谢

最佳答案

您可以使用 xpath starts-with功能

"//*[starts-with(@id, 'defaultSwatchContainer_')]/div/div/ul/li[list]"

关于java - 如何在 Selenium Webdriver 的 xpath 中选择具有动态值的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21189736/

24 4 0
文章推荐: java - ListView 中的切换控件获取 UnsupportedOperationException : addView(View, LayoutParams) 在 AdapterView 中不受支持
文章推荐: java - Spring许多mamcached实现
文章推荐: java - PdfCopy 中的 iText mergeFields 创建无效的 pdf
文章推荐: java - 如何修复 JAVA VS 代码中的实现错误, "must implement the inherited abstract class"
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com