Control + key presses using action chains does not work
See original GitHub issueThe 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:
- Created a year ago
- Comments:17 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This API was previously only working on macOS. It only supports iPadOS since v15 and is obviously not supported by WDA
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