gpt4 book ai didi

css - 使用 StoreValue 时,Selenium 声明 "This element has no value"

转载 作者:行者123 更新时间:2023-11-28 12:22:03 26 4
gpt4 key购买 nike

我有以下代码,我需要在其中获取值:

<a href="/checkout/cart.jsf">
Items:
<span class="numberofitems">1</span>
</a>

但是,当我尝试使用 css=span [class='numberofitems'] 指向它时,我收到消息“该元素没有值;它真的是一个表单域吗?”该元素确实有一个我可以在 Firebug 中看到的值,但我不知道如何正确存储这个值。

最佳答案

开始吧.. 下面给出的每个 WebElements 都会给出更好的结果以获得值 '1'

By.xpath("//a[@href='/checkout/cart.jsf']/span")

By.xpath("//a[text()='Items: ']/span"))

By.xpath("//span[@class='numberofitems']")

如果他们不工作,

  1. 在 Firebug 的帮助下检查元素是否隐藏。
  2. 检查类名'numberofitems'是否重复。

关于css - 使用 StoreValue 时,Selenium 声明 "This element has no value",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18808876/

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