运用python+selenium批量简略网站消息

from selenium import webdriver

from selenium.webdriver.support.wait import WebDriverWait

import win32gui, win32con, time, os, shutil

driver = webdriver.Chrome()

driver.get("http://www.test.com/admin.php")

time.sleep(2)

username = driver.find_element_by_xpath('//input[@placeholder="账号"]')

password = driver.find_element_by_xpath('//input[@placeholder="暗号"]')

presslogin = driver.find_element_by_xpath('//button[@type="submit"]')

username.send_keys("admin")            # 用户名

password.send_keys("password")           # 暗号

presslogin.click()

time.sleep(2)

n = 1

while n < 530:

   driver.get("http://www.test.com/admin.php?s=news&c=recycle&m=index")

    time.sleep(2)

    checkall = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div/form/div[1]/table/thead/tr/th[1]/label/input')

    time.sleep(2)

    driver.execute_script("arguments[0].click();", checkall)

    time.sleep(1)

    driver.find_element_by_xpath('//*[@id="myform"]/div[2]/div[1]/label[2]/button').click()

    time.sleep(2)

    WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id('layui-layer1'))

    time.sleep(2)

    delall = driver.find_element_by_xpath('//*[@id="layui-layer1"]/div[3]/a[1]')

    time.sleep(2)

    driver.execute_script("arguments[0].click();", delall)

time.sleep(5)

n = n +1

else:

print("简略结束")