ui自动化从登录到新增数据
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
# 通过ID来定位
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.jdy.com/login/') # 打开网站
sleep(3)
driver.find_element(By.ID, 'login_username').send_keys("输入账号") # 输入账号
driver.find_element(By.ID, "login_pwd").send_keys("输入密码") # 输入密码
driver.find_element(By.ID, "login_btn").click() # 点击登录
driver.find_element(By.ID, "agree-protocol").click() # 点击同意-跳转至
driver.find_element(By.LINK_TEXT, "取消").click() # 取消提示弹框
driver.find_element(By.LINK_TEXT, "进入使用").click() # 进入使用
sleep(3)
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click() # 点击新增
sleep(3)
# # 输入数据
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[2]/form/div[2]/div/div/input').send_keys("交通")
# driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[2]/form/div[3]/div/div/div/input').click()
sleep(3)
# 新增保存
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click()
sleep(2)
# 修改保存
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click()
sleep(3)
# # 关闭页面
driver.find_element(By.XPATH, '//*[@id="tab-/webpage/managerEdit/:id"]/span').click()
sleep(3)
driver.get_screenshot_as_file('1.出现一条交通数据.png')
sleep(3)
driver.quit()
from time import sleep
from selenium.webdriver.common.by import By
# 通过ID来定位
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.jdy.com/login/') # 打开网站
sleep(3)
driver.find_element(By.ID, 'login_username').send_keys("输入账号") # 输入账号
driver.find_element(By.ID, "login_pwd").send_keys("输入密码") # 输入密码
driver.find_element(By.ID, "login_btn").click() # 点击登录
driver.find_element(By.ID, "agree-protocol").click() # 点击同意-跳转至
driver.find_element(By.LINK_TEXT, "取消").click() # 取消提示弹框
driver.find_element(By.LINK_TEXT, "进入使用").click() # 进入使用
sleep(3)
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click() # 点击新增
sleep(3)
# # 输入数据
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[2]/form/div[2]/div/div/input').send_keys("交通")
# driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[2]/form/div[3]/div/div/div/input').click()
sleep(3)
# 新增保存
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click()
sleep(2)
# 修改保存
driver.find_element(By.XPATH, '//*[@id="app"]/div[1]/div[2]/div[3]/div[1]/div/button[1]').click()
sleep(3)
# # 关闭页面
driver.find_element(By.XPATH, '//*[@id="tab-/webpage/managerEdit/:id"]/span').click()
sleep(3)
driver.get_screenshot_as_file('1.出现一条交通数据.png')
sleep(3)
driver.quit()
生命不断追求不止