1
我試圖在Google搜索字段中插入一個值。 這裏是IPython的代碼:在Selenium中編輯文本字段
In [1]: from selenium import webdriver
In [2]: driver=webdriver.Chrome("/ChromeDriver/chromedriver")
In [3]: driver.get("https://www.google.com/")
In [4]: i=driver.find_elements_by_id("lst-ib")[0]
In [5]: i.click()
In [6]: i.sendKeys("test")
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-dcc9ebf0e928> in <module>()
----> 1 i.sendKeys("test")
AttributeError: 'WebElement' object has no attribute 'sendKeys'
In [7]: i.setAttribute("value","test")
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-cf9217d1c7f8> in <module>()
----> 1 i.setAttribute("value","test")
AttributeError: 'WebElement' object has no attribute 'setAttribute'
i
是谷歌搜索輸入字段,我不能與填充值。 有誰知道如何在這個字段中插入值?