Difference between WebElement, MobileElement, AndroidElement, and iosElement

Can anyone please explain what happen if we use WebElement, MobileElement, AndroidElement and IOS Element??

I have used WeElement for web application. When I started Appium I used WebElement and everything is working fine but I dont know the exact difference between these.

2 Likes

Hi @Deepa_S,

Apparently, I believe WebElement is for identification of Web Based element using WebDriver, Android,iOS & Mobile elements are specific to AppiumDriver abstract class in Appium client libraries.

We need some clarification on all the above…Could you please let us know if any one knows exactly.!!!

@jonahss @Appium_Master @sebv @rgonalo @willosser @Hassan_Radi @kirill
Thanks,
Bhaskar.

2 Likes

WebElement is a general interface that all the other classes (RemoteWebElement, MobileElement, AndroidElement, IOSElement) implement. which means that if you have an object of type WebElement it will have all the basic functions a web element can have. If you need more specific functions you can use other objects like: RemoteWebElement, MobileElement, AndroidElement, IOSElement

Also note that WebElement & RemoteWebElement are bundled with Selenium while MobileElement, AndroidElement & IOSElement are specific to Appium.

For a list of the specific functions in each of them please refer to:
RemoteWebElement, MobileElement, AndroidElement, IOSElement.

9 Likes

Basically, using WebElement will let you use all the normal Selenium commands. MobileElement is appium’s element which subclasses WebElement and adds appium-specific features (like being able to perform Touch Gestures).
AndroidElement and IOSElement implement MobileElement and add OS-specific features. Like on Android you can use findByUIAutomator and on iOS you can use findByUIAutomation

11 Likes

Thank you Jonahss… nice explanation…

1 Like

One of the biggest difference is that if you want to locate elements on mobile device using findElementByAccessibilityId(locator) then you have to use MobileElement. If you use WebElement then you will not be allowed to findElementByAccessibilityId(locator).