Access Clipboard Data Via Appium+Python

83 views Asked by At

I am new to appium and have been trying to access clipboard data from an android device(V 13.0) using Appium and python.

I tried using get_clipboard() but this throws the belowerror

base64_str = self.execute(Command.GET_CLIPBOARD, {'contentType': content_type})['value']
TypeError: 'NoneType' object is not subscriptable

I am attaching the code below

from appium import webdriver
from appium.webdriver.extensions.clipboard import Clipboard
from appium.options.android import UiAutomator2Options
caps = {"appium:platformName": "Android", "appium:platformVersion": "13.0", "appium:deviceName": "Oneplus Nord2 5G",
        "appium:automationName": "UiAutomator2", "appium:udid": "9TQC6LF65TW8LJ6L", "appium:newCommandTimeout": 3600,
        "appium:connectHardwareKeyboard": True}
capabilities_options = UiAutomator2Options().load_capabilities(caps)
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", options=capabilities_options)
Text = Clipboard()

ReturnVal = Text.get_clipboard()

After going through different pages I found out that get_clipboard() is not supported for higher version of Android.

I am looking for a solution which can be used both on android and ios.

Can you all please suggest an workaround?

0

There are 0 answers