简体   繁体   中英

Python keyboard enter isnt working on a website while every other key is

from selenium import webdriver
import pynput
from pynput.keyboard import Key, Controller
import json

keyboard = Controller()
#json part

with open('daten.json') as file:
        data = json.load(file)

driver = webdriver.Chrome()
driver.get('https://srsbstudy.typeform.com/to/ZNqPzv')

Name = driver.find_element_by_id('email-7c971ed6b4be6cc6') 
Name.send_keys(data["Mail"])

keyboard.press("enter")

*If i now let ir run I keep getting a error:

driver = webdriver.Chrome()
driver.get('https://srsbstudy.typeform.com/to/ZNqPzv')

Name = driver.find_element_by_id('email-7c971ed6b4be6cc6') 
Name.send_keys(data["Mail"])

keyboard.press("enter")

I need help and tryed everything possible for me. If i change the "enter" to "a" it works but i need the enter. Thanks

You should use Key.enter instead of "enter" . If you need to use another "special" key like esc basically do Key.key_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM