Beispiel #1
0
class TestAppiumUtil:

    def setup(self):
        print('Test start.')
        # config_path = '/Users/jameszhang/python/project/appCrawler/test/testdata/config/NBA_Android_config.yml'
        config_path = os.path.join(os.path.dirname(__file__), 'testdata/config', 'NBA_Android_config.yml')
        uid = device_info_util.get_serial_numbers_android()
        self.config = Config(config_path, uid[0])

    def teardown(self):
        print('Test end.')
        del self.config

    def test_appium_init_driver(self):
        self.driver = Appium(self.config.appium_desired_caps())
        self.driver.quit()

    def test_save_page_source(self):
        self.driver = Appium(self.config.appium_desired_caps())
        time.sleep(20)
        page_source = self.driver.get_page_source()
        date = str(int(time.time()))
        with open('testdata/pageSource/{}.xml'.format(date), 'w', encoding='utf-8') as fp:
            fp.write(page_source)

        self.driver.quit()
Beispiel #2
0
class TestConfigData:
    def setup(self):
        print('Test start.')
        self.config = Config(
            '/Users/jameszhang/python/project/appCrawler/test/testdata/config/NBA_Android_config.yml'
        )

    def teardown(self):
        del self.config
        print('Test end.')

    def test_get_attr_str(self):
        platform_name = self.config.platformName
        assert platform_name == 'Android'

    def test_get_attr_list(self):
        list_data = self.config.test_list
        for i in range(1, 4):
            assert list_data[i - 1] == i

    def test_get_attr_error(self):
        with pytest.raises(expected_exception=AttributeError):
            self.config.error_attr

    def test_get_appium_desired_caps(self):
        desired_caps = self.config.appium_desired_caps()
        assert desired_caps['appPackage'] == 'com.nbaimd.gametime.nba2011'
        assert desired_caps[
            'appActivity'] == 'com.neulion.nba.base.LaunchDispatcherActivity'

    def test_white_apps(self):
        white_apps = self.config.white_apps()
        assert isinstance(white_apps, Set)
        assert "com.nbaimd.gametime.nba2011" in white_apps
Beispiel #3
0
 def setup(self):
     print('test start')
     uid = device_info_util.get_serial_numbers_android()
     config_path = os.path.join(os.path.dirname(__file__), 'testdata',
                                'config', 'NBA_Android_config.yml')
     config = Config(config_path, uid[0])
     screenshot = os.path.join(os.path.dirname(__file__),
                               'testdata\\screenshot')
     if not os.path.exists(screenshot):
         os.mkdir(screenshot)
     self.driver = Appium(config.appium_desired_caps())