1

Chrome、有料の拡張機能、Python、ChromeDriverを使用して、クライアントの面倒な作業を自動化しています。特定のページを読み込んでから、ブラウザの拡張機能アイコンをクリックして、そのページに基づいてポップアップを表示する必要があります。アイコンのクリックを自動化するより良い方法は見つからなかったので、その拡張機能を開始するためのホットキーを設定しています。
Chrome 54とChromeDriver 2.25を使用していますが、今はホットキーを送信できません。
これは、旧バージョン(拡張のためのホットキーを設定せず)で働いていた:私はbodyタグ経由で任意のホットキーを送信することはできませんChromedriverを使用してChromeでホットキー(ショートカット)を使用できない

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() 

、私が試してみました。私は入力フォームにのみ文字を送ることができます、ホットキーはそれで動作しません。

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 

は私もヒットした何を慰めるために書くためにJavaScriptコードを添付し、そして私は「メートル」を参照してくださいことはできません。
私も次のような結果とJavaのを試してみました。ロボットは何もコンソールに書き込まなかった。
私はこの問題で私が完全に一人であると感じ始めています。それは本当に誰も苦しんでいないのですか?助けてください!

+0

私は現在、クロム61、ChromeDriver 3.6で同じ問題が発生していますを使用することです。あなたは解決策を見つけましたか? –

+0

ええ、私もその問題を見ましたが、私を助けてくれなかった、私はそのプロジェクトを失った:D – monami

答えて

関連する問題