webdriver定位元素方法:
- id find_element_by_id()
- name find_element_by_name()
- class name find_element_by_class_name()
- tag name find_element_by_tag_name()
- link text find_element_by_link_text() find_element_by_link_text("新闻")
- partial link text find_element_by__partial_link_text()
- xpath find_element_by_xpath()
- css selector find_element_by_css_selector()
#coding=utf-8
from selenium import webdriver
import time
driver= webdriver.Firefox()
driver.get("http://www.cqlw.com/site/login.action?sourceUrl=")
driver.find_element_by_xpath("/html/body/div/form/table/tbody/tr/td[2]/div[4]/input").clear
driver.find_element_by_xpath("/html/body/div/form/table/tbody/tr/td[2]/div[4]/input").send_keys("ldd007")
driver.find_element_by_xpath("/html/body/div/form/table/tbody/tr/td[2]/div[7]/input").clear
driver.find_element_by_xpath("/html/body/div/form/table/tbody/tr/td[2]/div[7]/input").send_keys("222222")
driver.find_element_by_id("sub").click()
driver.quit()