<input type="text" name="passwd" id="passwd-id" />
文字输入、点击
element.send_keys("some text") #文本框文字输入
element.send_keys(" and some", Keys.ARROW_DOWN) #文字输入+按键
element.clear() #文本框清空
element.click() #点击
Options选择
from selenium.webdriver.support.ui import Select
select = Select(driver.find_element_by_name('name'))
select.select_by_index(index)
select.select_by_visible_text("text")
select.select_by_value(value)
返回、前进
driver.get("http://www.example.com")
driver.forward()
driver.back()
添加Cookies
# Go to the correct domain
driver.get("http://www.example.com")
# Now set the cookie. This one's valid for the entire domain
cookie = {‘name’ : ‘foo’, ‘value’ : ‘bar’}
driver.add_cookie(cookie)
# And now output all the available cookies for the current URL
driver.get_cookies()