1

I am automating a cumbersome task of my client, using Chrome, a paid extension, python and ChromeDriver. I have to load a specific page and then to click on the Extension icon in the browser, so it will display a popup based on the page. I didn't find a better way to automate the click on the icon, so I'm setting a hotkey for that extension to start.
I'm using Chrome 54 and ChromeDriver 2.25, and now I cannot send any hotkeys.
This worked with older versions (without setting the hotkey for extension):

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import selenium.webdriver.chrome.service as service

ext_folder = os.environ["LOCALAPPDATA"] + "\\Google\\Chrome\\User Data\\Default\\Extensions\\blabla"

chrome_options = Options()
chrome_options.add_argument("load-extension=" + ext_folder)
chrome_path = "Path\\To\\chromedriver.exe"
service = service.Service(chrome_path)
service.start()
capabilities = {'chrome.binary': chrome_path}
browser = webdriver.Remote(service.service_url, desired_capabilities=chrome_options.to_capabilities())

browser.get('https://amazon.com')
browser.find_element(By.TAG_NAME, "body").send_keys(Keys.CONTROL + "m") # this would start the extension, but nothing happens
browser.quit()

I can't send any hotkey via body tag, I tried. I can only send letters to an input form, hotkey doesn't work with it, either.
I even tried Java with the following results:

Actions actions = new Actions(browser);
actions.keyDown(Keys.CONTROL).sendKeys("m").perform();  // doesn't work
actions.sendKeys(Keys.chord(Keys.ESCAPE)).perform();  // doesn't work
actions.sendKeys(Keys.chord(Keys.CONTROL, "m")).perform();  // doesn't work
WebElement body = browser.findElement(By.tagName("body"));
body.sendKeys(Keys.chord(Keys.ESCAPE));  // doesn't work
body.sendKeys(Keys.chord(Keys.CONTROL, "m"));  // doesn't work
Robot bot = new Robot();
bot.keyPress(KeyEvent.VK_CONTROL);
bot.keyPress(KeyEvent.VK_M);
bot.keyRelease(KeyEvent.VK_M);
bot.keyRelease(KeyEvent.VK_CONTROL);  // doesn't work

I even attached a javascript code to write to console what's has been hit, and I can never see the "m". Robot didn't write anything to the console.
I'm starting to feel that I am completely alone with this problem. Is really noone suffering from this? Please help!

monami
  • 594
  • 2
  • 9
  • 32

1 Answers1

0

This appears to have been an open issue since Mar 2012. It is specific to Chrome on OSX. https://bugs.chromium.org/p/chromedriver/issues/detail?id=30 The recommended work around is to use Alternate Shortcut keys Performing a copy and paste with Selenium 2

running-codebase
  • 998
  • 2
  • 12
  • 17