from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://localhost/15430/*******')
driver.find_element_by_id("firstName").send_keys("acs2015")
driver.find_element_by_id("userName").send_keys("b15430")
driver.find_element_by_id("password").send_keys("admin")
driver.find_element_by_name("login").click()
driver.implicitly_wait(10)
driver.find_element_by_xpath("//*[@class='navigation-item datagrid']").click()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[3]/div[3]/div[3]/ul/li[11]/span").click()
driver.find_element_by_xpath("//*[@id='main']/div[2]/div[2]/div/div[2]/div[1]/div[1]/div/div/div[2]/div/div[1]/div[3]/div[1]/table/tbody/tr[1]").click()
action = ActionChains(driver)
action.double_click(driver.find_element_by_xpath("//*[@id='main']/div[2]/div[2]/div/div[2]/div[1]/div[1]/div/div/div[2]/div/div[1]/div[3]/div[1]/table/tbody/tr[1]")).perform()
s = "//*[@id='main']/div[2]/div[2]/div/div[2]/div[1]/div[1]/div/div/div[2]/div/div[1]/div[3]/div[1]/table/tbody/tr[{}]";
for i in range(1, 20):
name = s.format(i+1)
driver.find_element_by_xpath(name).click()
sleep(20)
遇到难点:
一个是定位
二个是依次遍历和点击