0

I have a dropdown which is disabled and I have to verify the same. How can I do it with an assert statement or any other method?

  • Which language binding ? Java ? C# ? J's – PDHide May 14 at 13:39
  • What is the purpose of validating the values of a disabled dropdown, given that your users can't use it? – João Farias May 14 at 21:02
0

You can select the dropdown WebElement this way;

WebElement testDropDown = driver.findElement(By.id("testingDropdown"));  
Select dropdown = new Select(testDropDown);

But to check whether it is disabled, you can use isEnabled();

boolean isEnabledDropDown = driver.findElement(By.xpath("dropdown_xpath")).isEnabled();

Check the isEnabled() documentation

Therefore to assert that;

Assert.assertTrue(isEnabledDropDown);
| improve this answer | |
0

In case isEnabled is not working:

  1. Verify the DOM which may be having some attributes to represent it is disabled
  2. And then use element.getAttribute("attName");

If it doesn't work, you can go with the exception. Try to select a value as mentioned in the above code, surround it with try block and capture the result in your catch block.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.