When I press the CTRL+SHIFT+2 anywhere on Windows/Mac I open a (PhraseExpress) form that pops up. I would like to mimic that in Selenium. Ideally it should work on both Windows and Mac. Now I try to get it to work on Windows with send_keys and ActionChains.
def open_form() -> None:
"""function to open the corresponding phraseexpress form (with a hotkey)."""
bodyElement = WebDriverWait(driver, 40).until(
EC.element_to_be_clickable((By.TAG_NAME, "body"))) #get a random element to perform send-keys action on.
# create action chain object
actions = ActionChains(driver)
if fullstring == "Note 2":
if platform == "win32": #if on Windows
actions.key_down(Keys.CONTROL).key_down(Keys.SHIFT).send_keys_to_element(bodyElement, "2").key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform()
#actions.key_down(Keys.CONTROL).key_down(Keys.SHIFT).send_keys('2').key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform() # I tried this as well
#pyautogui.hotkey('ctrl', 'shift', '2') #This is working but I would like to use the above method instead, hoping it will work on Mac as well. This hotkey does not work on Mac. I think the hotkey is executed in Terminal instead of the OS, hence nothing happens.
print("You opened PhraseExpress for Note 2")
The output in terminal is "You opened PhraseExpress for Note 2" but the form does not pop up. The key presses does not trigger the form on the OS. Any idea what can be done? Why is this action not working when pyautogui.hotkey() does work?