python - 与selenium的奇怪错误

时间:2014-03-13 17:10:43

标签: python selenium selenium-webdriver

我的代码:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException

site = "https://blockchain.info/wallet/login"
identifier = "myIdentifier"


browser = webdriver.Firefox()
browser.get(site)
browser.find_element_by_xpath('/html/body/div[5]/div[4]/div/div/div[2]/div/div/input'.send_keys(identifier)

我运行它,我收到此错误: a busy cat http://gyazo.com/897fe2b83db36585b3521cc1a06aa832.png

更大的图片:http://gyazo.com/897fe2b83db36585b3521cc1a06aa832

我在那条线之后尝试过评论,上下移动但是我不知道这里有什么问题

2 个答案:

答案 0 :(得分:3)

替换:

browser.find_element_by_xpath('/html/body/div[5]/div[4]/div/div/div[2]/div/div/input'.send_keys(identifier)

使用:

browser.find_element_by_xpath('/html/body/div[5]/div[4]/div/div/div[2]/div/div/input').send_keys(identifier)

观察结束) - 首先找到一个元素,然后发送密钥。

答案 1 :(得分:0)

你错过了一个结束括号。 试试这个。

browser = webdriver.Firefox()
browser.get(site)
browser.find_element_by_xpath('/html/body/div[5]/div[4]/div/div/div[2]/div/div/input').send_keys(identifier)