Mobile App Automation Testing Via Appium With Python
Mobile App Automation Testing Via Appium With Python

The release of Mobile App Automation Testing Via Appium With Python at Vivify Healthcare is part of the company’s research and development efforts to find the best technology stack that is both sustainable and affordable.
The company is constantly looking for ways to improve its offerings and stay ahead of the curve in the highly competitive healthcare industry. By Utilizing the leading and open-source platform for transforming; how people / organizations get benefited by using Mobile App Automation Testing Via Appium With Python .
Vivify Healthcare aims to deliver a top-notch user experience while keeping costs low and maintaining stability, security and compliance. Mobile App Automation Testing Via Appium With Python provides a flexible, scalable solution that can be easily adapted to meet the changing needs of the business and its customers.

Appium is an open-source mobile application testing framework that allows you to automate testing of native, hybrid, and mobile web applications across various platforms, such as iOS and Android. It provides a cross-platform solution for automating mobile app testing.

Appium is an open-source mobile application testing framework that allows you to automate testing of native, hybrid, and mobile web applications across various platforms, such as iOS and Android. It provides a cross-platform solution for automating mobile app testing, enabling you to write tests using familiar programming languages like Java, C#, Python, Ruby, and JavaScript.

  • It is developed and supported by Sauce Labs and has great community support.
  • Appium is cross-platform as it allows the same API which works for different mobile operating systems.
  • Appium Testing is flexible, you can use the same code ios that you have written for Android.
  • One of the key features of Appium is its ability to automate tests using the WebDriver protocol, which allows you to interact with mobile apps in a similar way to how you would interact with a web page in a browser. This means you can perform actions like tapping buttons, entering text, swiping, and validating UI elements within your tests.

Features:

  1. Multi-language support
  2. Simplicity and ease of use
  3. Real device and emulator/simulator support
  4. Support for gestures and touch events
  5. Integration with testing frameworks
  6. It supports both Android and iOS

Steps to Setup 

Screenshot 2023-06-06 115325

  • After download Appium Inspector, Complete the installation process then Open the Appium inspector
  • In Appium Server and Appium Inspector “Host and Remote Host” are needs to be same
  • In Appium Server and Appium Inspector “Port and Remote Port” are needs to be same

  • With Appium 2.0, you should also ensure you’re sending W3C standard capabilities within your test code such as the following capabilities:

  • Create new python project in Pycharm
  • Set the Interpreter and add the Appium dependency for the project
  • Open Settings and Click on Project Interpreter, Click ‘+‘ and then search for Appium in Available Packages dialog box.
  • Select Appium-Python-Client and click Install Package to install Appium Python Client.

Appium Test Execution- Example Set:

  • App : Flipkart
  • Description : Hear we are testing the flipkart app via Appium with Python and we are getting the laptop price in the console window
  • First you need to create a .py file in that you have to write your code.
  • Example Code :

from appium import webdriver
from appium.options.android import UiAutomator2Options

options = UiAutomator2Options()
options.platform_name = ‘Android’
options.platformVersion = ‘7.1.2’
options.device_name = ‘google G011A’
options.automation_name = ‘Appium’
options.app_activity = ‘MainActivity’
driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, options=options)

driver.find_element(‘xpath’,’//android.widget.TextView[@index=”9″]’).click()
driver.implicitly_wait(50)

# search lenovo laptops
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/’
‘android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.TextView’).click()
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup[1]/android.widget.EditText’).send_keys(‘lenovo laptops’)
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup/android.view.ViewGroup[1]’).click()

price = driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[1]/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup/android.widget.TextView[4]’).get_attribute(“text”)

assert price == “₹33,990″,”Price not same”

print(“Laptop price = ” + price)from appium import webdriver
from appium.options.android import UiAutomator2Options

options = UiAutomator2Options()
options.platform_name = ‘Android’
options.platformVersion = ‘7.1.2’
options.device_name = ‘google G011A’
options.automation_name = ‘Appium’
options.app_activity = ‘MainActivity’
driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, options=options)

driver.find_element(‘xpath’,’//android.widget.TextView[@index=”9″]’).click()
driver.implicitly_wait(50)

# search lenovo laptops
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/’
‘android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.TextView’).click()
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup[1]/android.widget.EditText’).send_keys(‘lenovo laptops’)
driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup/android.view.ViewGroup[1]’).click()

price = driver.find_element(‘xpath’,’/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup[1]/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup[1]/’
‘android.view.ViewGroup/android.widget.TextView[4]’).get_attribute(“text”)

assert price == “₹33,990″,”Price not same”

print(“Laptop price = ” + price)

Result:

Skip to content