def test_push_pull_file(self): dest_path = '/data/local/tmp/test_push_file.txt' data = appium_bytes('This is the contents of the file to push to the device.', 'utf-8') self.driver.push_file(dest_path, base64.b64encode(data).decode('utf-8')) data_ret = base64.b64decode(self.driver.pull_file(dest_path)) self.assertEqual(data, data_ret)
def set_clipboard_text(self, text, label=None): """Copies the given text to the system clipboard Args: text (str): The text to be set label (:obj:`int`, optional):label argument, which only works for Android """ self.set_clipboard(appium_bytes(str(text), 'UTF-8'), ClipboardContentType.PLAINTEXT, label)
def set_clipboard_text(self, text, label=None): """ Copies the given text to the system clipboard :param text: The text to be set :param label: Optional label argument, which only works for Android """ self.set_clipboard(appium_bytes(str(text), 'UTF-8'), ClipboardContentType.PLAINTEXT, label)
def test_push_pull_file(self): dest_path = '/data/local/tmp/test_push_file.txt' data = appium_bytes( 'This is the contents of the file to push to the device.', 'utf-8') self.driver.push_file(dest_path, base64.b64encode(data).decode('utf-8')) data_ret = base64.b64decode(self.driver.pull_file(dest_path)) self.assertEqual(data, data_ret)
def test_pull_folder(self): data = appium_bytes('random string data {}'.format(random.randint(0, 1000)), 'utf-8') dest_dir = '/data/local/tmp/' for filename in ['1.txt', '2.txt']: self.driver.push_file(os.path.join(dest_dir, filename), base64.b64encode(data).decode('utf-8')) folder = self.driver.pull_folder(dest_dir) with ZipFile(BytesIO(base64.b64decode(folder))) as fzip: for filename in ['1.txt', '2.txt']: self.assertTrue(filename in fzip.namelist())
def test_set_clipboard_with_url(self): driver = TestHelper.mock_android_driver() httpretty.register_uri( httpretty.POST, 'http://localhost:4723/wd/hub/session/1234567890/appium/device/set_clipboard', body='{"value": ""}') driver.set_clipboard(appium_bytes(str('http://appium.io/'), 'UTF-8'), ClipboardContentType.URL, 'label for android') d = json.loads(httpretty.last_request().body.decode('utf-8')) assert d['content'] == 'aHR0cDovL2FwcGl1bS5pby8=' assert d['contentType'] == 'url' assert d['label'] == 'label for android'
def test_set_clipboard_with_url(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/set_clipboard'), body='{"value": ""}') driver.set_clipboard(appium_bytes(str('http://appium.io/'), 'UTF-8'), ClipboardContentType.URL, 'label for android') d = get_httpretty_request_body(httpretty.last_request()) assert d['content'] == 'aHR0cDovL2FwcGl1bS5pby8=' assert d['contentType'] == 'url' assert d['label'] == 'label for android'
def test_pull_folder(self): data = appium_bytes( 'random string data {}'.format(random.randint(0, 1000)), 'utf-8') dest_dir = '/data/local/tmp/' for filename in ['1.txt', '2.txt']: self.driver.push_file(os.path.join(dest_dir, filename), base64.b64encode(data).decode('utf-8')) folder = self.driver.pull_folder(dest_dir) with ZipFile(BytesIO(base64.b64decode(folder))) as fzip: for filename in ['1.txt', '2.txt']: self.assertTrue(filename in fzip.namelist())
def test_set_clipboard_with_url(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/set_clipboard'), body='{"value": ""}' ) driver.set_clipboard(appium_bytes(str('http://appium.io/'), 'UTF-8'), ClipboardContentType.URL, 'label for android') d = get_httpretty_request_body(httpretty.last_request()) assert d['content'] == 'aHR0cDovL2FwcGl1bS5pby8=' assert d['contentType'] == 'url' assert d['label'] == 'label for android'