[笔记]Selenium Testing Tools Cookb

2020-02-11  本文已影响0人  elf_fff

Chapter 14 Testing Applications on Mobile Browsers

14.1 Setting up Appium for testing mobile applications

14.2 Testing mobile web applications on iOS using Appium

import unittest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class JianShu(unittest.TestCase):
    def setUp(self):
        # set the desired capabilities for iOS
        caps = DesiredCapabilities.FIREFOX.copy()
        caps['platformName'] = 'iOS'
        caps['platformVersion'] = '13.3'
        caps['deviceName'] = 'iPhone 7'
        caps['browserName'] = 'safari'
        #caps['bundleId'] = 'com.apple.mobilesafari'
        # Instantiate an instance of Remote WebDriver with the desired capabilities
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub',\
            caps)
        # open the page
        self.driver.get('https://www.jianshu.com')

    def testJianShu(self):
        Button = self.driver.find_element_by_xpath('//XCUIElementTypeStaticText[@name="一个优质创作社区"]')
        Button.click()

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
上一篇 下一篇

猜你喜欢

热点阅读