简体   繁体   English

Python Selenium:send.keys可以和输入一样吗?

[英]Python Selenium: Can `send.keys` be `=` to `input`?

So i have a little question: I want my small program to have to have an input of the users Destination/Hotel name and then sending the input to the website. 所以我有一个小问题:我希望我的小程序必须输入用户的目的地/酒店名称,然后将输入发送到网站。 Below is my code, please help if you know how to make the send.keys and input work. 以下是我的代码,如果您知道如何使send.keysinput起作用,请提供帮助。 Thanks! 谢谢!

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

browser = webdriver.Firefox()
browser.get('http://www.booking.com/')

class Search:
    def Destin_Hotel_Name(self):    
        D_H_Name= browser.find_element_by_id('ss') 
        print("Enter Destination/Hotel Name: ")
        D_H_Name.send_keys(input())

Search.Destin_Hotel_Name(self)

send_keys is a function that receives the text as parameter, you can't use it this way. send_keys是一个接收文本作为参数的函数,您不能以这种方式使用它。 The correct way is like this 正确的方法是这样的

D_H_Name.send_keys(input())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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