Reputation: 1141
I would like to sent 'COMMAND' + '+'. I am struggling already with 'COMMAND' + 'a' - nothing happens when i run this code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
url = 'https://www.google.com'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(3)
body = driver.find_element_by_tag_name('body')
body.send_keys(Keys.COMMAND, 'a')
time.sleep(3)
driver.quit()
Am i doing something wrong or is it simply not possible to send keys with chrome and selenium.webdriver?
What is the right name in python for '+' - is it Keys.ADD?
Upvotes: 3
Views: 4993
Reputation: 473873
I can reproduce the problem on Mac OS and Chrome too. There is an open related issue here:
Also see related issues:
As a workaround, run the tests involving sending keys to the browser in Firefox.
As an another workaround, specifically to COMMAND
+ +
(zooming in), set the zoom
style:
driver.execute_script("document.body.style.zoom = '150%';")
Upvotes: 4