Want to get an attribute of an element - Android/Ruby


I want to get the attribute of the toggle button in an android app.

There are few posts mentioning the I can use get_attribute to get the “checked” property.
But when I try that I get this error,


NoMethodError: undefined method `get_attribute’ for #Selenium::WebDriver::Element:0x4452200866329d26 id=“9”

I am using Appium with ruby. I tried the above in ruby console(arc)

Is there any other way to get the attribute of the toggle button ? I want to check if the toggle button is on or off

1 Like

I’m not using ruby anymore, but can you try:


Edit: Look at this page https://github.com/appium/ruby_lib/blob/ad8bf400711005f32440618b370ee2551f172a7d/docs/docs.md

e.attribute('checked') # is the checkbox checked?

Thanks! it worked :smile: