Appium Interview Questions and Answers – Part 5 (10 Questions)
Q1) What are the different types of element locators used by Appium?
Answer: Appium supports all the locators that are supported by Selenium such as:
- > Class Name
- > ID
- > CSS Selectors
- > Name
- > XPath
- > Link Text
- > Partial Link Text
- > Tag Name
Along with the above locators, Appium also supports the below additional locators:
- > Accessibility ID
- > Image
Q2) What is the return type for driver.findElementByXPath(“some_xpath”) ?
Answer: The return type for the above statement is WebElement.
We need to convert WebElement to Mobile Element to perform any actions with Appium.
Type cast to Mobile Element. Below is the example for Type Cast:
MobileElement me = (MobileElement) driver.findElementByXPath(“//div/text-logo”);
Q3) How to enter text in text fields with Appium?
Answer: We can use Appium sendKeys() method. Below is the code:
driver.findElementByXPath(“//div/text-logo”).sendKeys(“Value To Enter”);
Q4) How to perform Click action in Appium?
Answer: We need to use click() method to perform Click action. Below is the code:
Q5) How to clear text in text field with Appium?
Answer: Sometimes text fields will have default values, before typing any text we need to clear the text field. We need to use clear() method.
MobileElement me = (MobileElement) driver.findElementsByXPath(“//div/text-logo”);
Q6) How to rotate screen of an App with Appium?
Answer: The following are the ways to rotate the App screen with Appium using landscape and portrait modes as shown below:
driver.rotate(“landscape”); //for rotation in landscape mode
driver.rotate(“portrait”); //for rotation in portrait mode
Q7) How to get Current Orientation?
Answer: driver.getOrientation(); needs to be used for getting the current orientation of the App screen.
Q8) How to lock phone with Appium?
Answer: driver.lockDevice(); needs to be used for locking the device using Appium.
Q9) How to Un-lock device with Appium?
Answer: driver.unlockDevice(); needs to be used for un-locking the device using Appium.
Q10) How to Toggle between Network data with Appium?
Answer: driver.toggleDevice(); needs to be used for switching the Network data service on/off. For this Android API should be >=21
Thank you for Reading this Article. Hope it helped you!!
Happy Learning 🙂
On a mission to contribute to the Software Testing Community in all possible ways.