question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Control + key presses using action chains does not work

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Jun 23, 2022

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

0reactions
krishtoautomatecommented, Sep 26, 2022

may be this can enhanced to support more hid events using apple private apis

https://github.com/kennytm/iphone-private-frameworks/tree/master/IOKit/hid

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pressing ctrl+t doesn't work in Selenium Webdriver using ...
I'm using windows so I use ActionChains(driver).send_keys(Keys.CONTROL, "t").perform() , however, this does nothing. I tried the following to ...
Read more >
key_down method - Action Chains in Selenium Python
This method automates this work. It should only be used with modifier keys (Control, Alt and Shift). Syntax – key_down(value, element=None).
Read more >
Tutorial On Handling Keyboard Actions In Selenium ...
To use ActionChains for performing keyboard actions in Selenium WebDriver, you need to first import the ActionChains module.
Read more >
Browser Automation with Python and Selenium - Dev Genius
Also, we can use modifier keys like CTRL or SHIFT to perform some compound/combined keypresses with the help of ActionChains class.
Read more >
What to press ctrl +c on a page in Selenium with python?
key_down() – This method performs the action sending a key press only and not releasing it. The key_down() method is a part of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found