gpt4 book ai didi

c# - 为什么 GetAttribute ("disabled") 返回 "true"而不是 "disabled"?

转载 作者:太空狗 更新时间:2023-10-29 21:27:33 31 4
gpt4 key购买 nike

在我的一些测试中,我必须确认在设置某些标志时某些 select2 下拉菜单被禁用。为了证实这一点,我发现以下策略似乎有效:

Assert.True(element.GetAttribute("disabled").Equals("true"));

当我检查元素时,我看到 disabled="disabled"。我的问题是为什么从 GetAttribute = "true" 返回的字符串不是“disabled”?

最佳答案

https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html

某些属性似乎只返回 bool 值,无论实际值是“真”还是“假”。残疾人就是其中之一。链接页面列出了所有被认为是 bool 值的属性,任何其他属性都应返回该属性的值。

引用链接页面最相关的部分:

"The following are deemed to be "boolean" attributes, and will return either "true" or null: async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, spellcheck, truespeed, willvalidate ". [Selenium : WebElement.getAttribute()]

关于c# - 为什么 GetAttribute ("disabled") 返回 "true"而不是 "disabled"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25995656/

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