Switch ON/OFF Button in Appium

Let’s see, How can you Switch ON/OFF button in Appium. In previous tutorials, You have seen, How to perform Assertion in Android. Now we will see, How can you handle the Switch On/OFF Button in Andriod Application.

 

In android, Switch ON/OFF is an important element. To perform ON/OFF in Appium you need to use tap(int fingers, int duration) method of MobileElement class. Also, you can use click() method to tap on the button but it’s good practice to use tap() method to perform the ON/OFF switch button.

 

Switch ON/OFF Button in Appium

To understand this, You can open the setting of your mobile phone and look at the WI-FI enable functionality. It’s a switch button.

Let’s understand it using a simple example. To perform On/Off you need to find the element and just perform tap() operation on this mobile element.

In above example, We have implemented the logic to Switch ON/OFF the Wi-Fi button. In this code, We are opening the App , Click on the Setting icon. Find the Wi-Fi button and make it ON.

 

Using this way, You can ON/OFF the Switch button in Andriod Mobile Application.

0 Comment

Leave a Reply