Asserting button states


The first screenshot shows the UI with 4 buttons, with High being selected. From Appium inspector, there is no property that represents the state of the button.

What is the best way for me to assert which button is pressed and selected?

Thanks in advance

1 Like

no way. only image recognition will help.

2 Likes

As per my understanding there is no way Appium can get us the state of element / css properties associated with it like a
text is under lined
color of an element
something like getcssValue() of selenium does not work because OF UIAutomator framework limitation.

@Aleksei

Is there any way I can read different attributes shown for an element like

Attributes : valid,visible,label,type,location,size,xpath

for e.g.
driver.findElement(By.id(“someid”) ).getAttribute(“name”); // This works it corresponds to content-desc in android

But I want to read other attributes like below syntax does not work do we have any other way to read them from mobile DOM, may be by using UIAutomator classes UISelect etc

driver.findElement(By.id(“someid”) ).getAttribute(“valid”);
driver.findElement(By.id(“someid”) ).getAttribute(“visible”);
driver.findElement(By.id(“someid”) ).getAttribute(“type”);
driver.findElement(By.id(“someid”) ).getAttribute(“location”);
driver.findElement(By.id(“someid”) ).getAttribute(“enabled”);

1 Like

well you can check driver.getPageSource(). if you can see here needed elements you can search here as workaround while Appium fails to find.

1 Like

Thankyou very much for information. But using page source how can I read an attribute value ?

pageSource is XML file. just take it as XML and do search on any language suitable for you.