Element Properties

is_displayed()

This method verifies whether MobileElement is located in a device within a visibility of screen or not.It doesn’t take any argument and it returns boolean value as true or false.

Syntax :

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")
element.is_displayed()

is_enabled()

This method verifies whether require MobileElement is enabled or not to perform actions such as entering a text,clicking on a button etc.It doesn’t take any argument and it returns boolean value as true or false.

Syntax :

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")
element.is_enabled()

is_selected()

This method verifies whether a MobileElement is selected or not.This method mostly applies only on checkboxes ,Radio buttons and other select options.

It doesn’t take any argument and it returns boolean value true if the element is checked or selected , otherwise it returns false.

Syntax :

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")
element.is_selected()

size property

This property is used to get the dimensions such as width and height for a given MobileElement. It doesn’t take any argument and it returns the value of width and height of a MobileElement.

Syntax :

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")
element.size

location property

This property is used to find the location of MobileElement in a current screen.It doesn’t take any argument and it returns x y coordinates of MobileElement.

Syntax :

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")
element.location

ElementProperties.py

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
import time

# Step 1 : Create "Desired Capabilities"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['automationName'] = 'UiAutomator2'
desired_caps['platformVersion'] = '10'
desired_caps['deviceName'] = 'Pixel3XL'
desired_caps['app'] = ('/Skill2Lead/Appium_Demo_App/Android/Android_Appium_Demo.apk')
desired_caps['appPackage'] = 'com.skill2lead.appiumdemo'
desired_caps['appActivity'] = 'com.skill2lead.appiumdemo.MainActivity'

# Step 2 : Create "Driver object"
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

element = driver.find_element(AppiumBy.ID,"com.skill2lead.appiumdemo:id/EnterValue")

# Step 3 : Get the data of required element.
print("Is Displayed : ",element.is_displayed())
print("Is Enabled : ",element.is_enabled())
print("Is selected : ",element.is_selected())
print("Size : ",element.size)
print("Location : ",element.location)

time.sleep(2)
driver.quit()