gpt4 book ai didi

java - WebElement 的 setAttribute() 方法

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:32:43 25 4
gpt4 key购买 nike

this question这两个答案都使用 setAttribute() 作为 WebElement 功能。但是,我在 Java 中找不到这个方法。 , C#也不Python文档,只有 getAttribute()。尝试使用最新的 Selenium 版本从 C# (Visual Studio) 和 Java (Eclipse) 中的 WebElement 对象调用此方法产生了相同的结果。

所以我的问题是,这种方法真的存在吗?

最佳答案

检查 selenium Python 后 API docssource code ,我可以得出结论 - 没有这样的方法。而且,WebDriver specification 里面什么也没有。本身。

要设置一个属性,通常会执行一个脚本:

elm = driver.find_element_by_id("myid")
driver.execute_script("arguments[0].setAttribute(arguments[1], arguments[2]);",
elm,
"attr_name",
"attr_value")

关于java - WebElement 的 setAttribute() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35136773/

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