Selenium Mobile Test Automation Script in Python with Appium

By | 01/10/2015

You can automate your Android testcases by Python language and use Appium. to do that, first start Appium server and run following code:

# -*- coding: UTF-8 -*-
import unittest
from appium import webdriver

class TestClass(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '4.4.2'
        desired_caps['deviceName'] = 'mahsum'
        desired_caps['newCommandTimeout'] = '60'
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
 
    def test_TextView(self):
        self.driver.find_element_by_xpath("//com.android.helloworld.EditText[@content-desc='arg1']")
    
    @classmethod
    def tearDownClass(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()

Leave a Reply

Your email address will not be published. Required fields are marked *

*