Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.2'
desired_caps['platformVersion'] = '8.1'
desired_caps['automationName'] = 'uiautomator2'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['app'] = PATH('../../../apps/selendroid-test-app.apk')

Expand All @@ -116,7 +117,8 @@ from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '7.1'
desired_caps['platformVersion'] = '11.4'
desired_caps['automationName'] = 'xcuitest'
desired_caps['deviceName'] = 'iPhone Simulator'
desired_caps['app'] = PATH('../../apps/UICatalog.app.zip')

Expand Down
11 changes: 9 additions & 2 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ def set_clipboard(self, content, content_type=ClipboardContentType.PLAINTEXT, la
:param label: Optional label argument, which only works for Android
"""
options = {
'content': base64.b64encode(content),
'content': base64.b64encode(content).decode('UTF-8'),
'contentType': content_type,
}
if label:
Expand All @@ -1285,7 +1285,14 @@ def set_clipboard_text(self, text, label=None):
:param text: The text to be set
:param label: Optional label argument, which only works for Android
"""
self.set_clipboard(bytes(text.encode('UTF-8')), ClipboardContentType.PLAINTEXT, label)

def _bytes(value, encoding):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to put this helper method into some separate helper module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so, but nothing method used bytes so far. I'd like to extract here in next time.

try:
return bytes(value, encoding) # Python 3
except TypeError:
return value # Python 2

self.set_clipboard(_bytes(str(text), 'UTF-8'), ClipboardContentType.PLAINTEXT, label)

def get_clipboard(self, content_type=ClipboardContentType.PLAINTEXT):
"""
Expand Down