Why does GetAttribute ("disabled") return "true" rather than "disabled"?

In some of my tests, I have to confirm that some select2 dropdown menus are disabled when certain flags are set. To confirm this, I found that the strategy shown below works:

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

When I check the item, I see disabled="disabled" . My question is: why is the string returned from GetAttribute = "true" not "disabled"?

+5
source share
1 answer

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

Some attributes seem to return only boolean values, regardless of whether the true value is "true" or "false." One of them is disabled. The linked page lists all the attributes that are considered logical values, any other attribute should return the attribute value.

Indication of the most relevant part of the linked page:

"The following are considered boolean attributes and return either true or null: async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled , drag and drop, completed, formnovalidate, hidden, undefined , iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reverseed, round, seamless, search, selection, spelling, veracity, willvalidate " . [ Selenium: WebElement.getAttribute () ]

+6
source

Source: https://habr.com/ru/post/1203214/


All Articles