appium: Control + key presses using action chains does not work

The problem

Sending CTRL + A and CTRL + C (basically copying typed text to the clipboard).

The code which does not work:

from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common import keys

action = ActionChains(self.driver)
print("CTRL + A")
action.move_to_location(0, 0).key_down(keys.Keys.CONTROL).send_keys('a').key_up(keys.Keys.CONTROL).perform()
print("CTRL + C")
action.move_to_location(0, 0).key_down(keys.Keys.CONTROL).send_keys('c').key_up(keys.Keys.CONTROL).perform()

text = self.driver.get_clipboard_text()

but this does not produce any output (no error messages).

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: Desktop version of Appium server on MacOS
  • Mobile platform/version under test: iOS 15
  • Real device or emulator/simulator: Simulator
  • Appium CLI or Appium.app|exe: .app

Details

I have text typed in a notepad application and I would like to copy it and take it in the clipboard. (I cannot use .text as I do not have a way to search for the text field either using Xpath to accessibility Id) We can assume that the text area is in focus while the above operation is being performed.

I am open to any other suggestions which do not use actionChains as well.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (1 by maintainers)

Most upvoted comments

This API was previously only working on macOS. It only supports iPadOS since v15 and is obviously not supported by WDA