Files
F6--/其它系统脚本/添加员工信息.py
2026-01-30 11:28:35 +08:00

124 lines
5.4 KiB
Python

# -*- coding:UTF-8 -*-
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
import time
import xlrd
import xlwt
import re
from xlutils.copy import copy
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import datetime
#获取基础信息
name = '15651006300'
password = 'Wamh523364'
option_chrome = webdriver.ChromeOptions()
option_chrome.add_argument('--headless')
http='https://m.f6car.cn/'
#driver = webdriver.Chrome(chrome_options=option_chrome)
driver = webdriver.Chrome(executable_path=r"C:\迅雷下载\python 暂存文件\Python\chromedriver.exe")
driver.maximize_window()
driver.implicitly_wait(2)
driver.get(http)
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[1]/div/div/input').send_keys(name)
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[2]/div/div[1]/input').send_keys(password)
driver.find_element_by_xpath('//*[@id="pane-username"]/form/div[3]/div/button/span').click()
time.sleep(5)#预设时间
#传值转换
#driver.switch_to.frame('weixin-page-iframe')
#time.sleep(0.1)
#driver.find_element_by_xpath().click().send_keys()
file = xlwt.Workbook()
table = file.add_sheet('sheet name', cell_overwrite_ok=True)
#打开excel文件
data = xlrd.open_workbook(r"C:\Users\admin\Desktop\Python脚本\图形界面自动化脚本\F6系统常用脚本\Excel通用存储位置.xls")
print(data)
table = data.sheet_by_index(0) # 通过索引顺序获取
h = table.nrows
l = table.ncols
print(u"表数据的行数为%s,列数为%s"%(h,l))
https='https://yunxiu.f6car.cn/kzf6/contactBook/contactBookList.do?page=view/index.html%23/' #进入页面
driver.get(https)
time.sleep(0.5)
#传值转换
driver.switch_to.frame('weixin-page-iframe')
time.sleep(1)
driver.find_element_by_xpath(
'//*[@id="pane-1"]/div/div[2]/div[1]/div[2]/button[1]').click()#点击添加员工
time.sleep(1)
#传值转换
#driver.switch_to.frame('weixin-page-iframe')
#time.sleep(5)
for i in range(1,h):
try:
starttime = datetime.datetime.now()
idMember0 =table.cell(i, 0).value #按行工号
idMember1 =table.cell(i, 1).value #按行姓名
idMember2 =table.cell(i, 2).value #按行四级部门
idMember3 =table.cell(i, 3).value #按行node
idMember4 =table.cell(i, 4).value #按行紧急联系人电话
#选择所属部门
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[2]/div[4]/div/div/span/div/div[2]/input').click()#点击所属部门
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="node'+idMember3+'"]/span').click()#点击所属部门node
time.sleep(0.2)
#'//*[@id="node265039"]/span'
#'//*[@id="au-popover-3755"]/div[1]/div[1]/input'
#点击操作
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[2]/div[1]/div/div/div/input').send_keys(idMember0)#输入工号
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[2]/div[2]/div/div/div[1]/input').send_keys(idMember1)#输入姓名
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[2]/div[3]/div/div/div[1]/input').send_keys(idMember4)#输入手机号
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[3]/div[2]/div/div/div[1]/div[2]/input').click()#点击职位
time.sleep(0.2)
driver.find_element_by_xpath(
'/html/body/div/div[3]/div[1]/ul/li[3]/span').click()#点击店长
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[7]/div/label[1]/span[1]/span').click()#点击开通账号
time.sleep(0.3)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[8]/div[1]/div/div/div/div/input').click()#点击角色
time.sleep(0.2)
driver.find_element_by_xpath(
'/html/body/div[7]/div[3]/div[1]/ul/li[2]/span').click()#点击前置仓业务员
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[1]/form/div[8]/div[2]/div/div/span/div/div[2]/input').click()#点击门店权限
time.sleep(0.2)
driver.find_element_by_xpath(
'//*[text()="全选"]').click()#点击您身边的康众汽配
time.sleep(0.2)
#传值转换
#driver.switch_to.frame('weixin-page-iframe')
#time.sleep(0.1)
#driver.find_element_by_xpath().click().send_keys()
driver.find_element_by_xpath(
'//*[@id="app"]/div/div[2]/div[2]/button[2]/span').click()#点击保存并继续
time.sleep(0.2)
endtime = datetime.datetime.now()
implement = (endtime - starttime).seconds
print(i,'@', idMember0,'@',implement)
time.sleep(1)
except:
print('失败')
https='https://yunxiu.f6car.cn/kzf6/contactBook/contactBookList.do?page=view/index.html%23/' #进入页面
driver.get(https)
time.sleep(0.5)
#传值转换
driver.switch_to.frame('weixin-page-iframe')
time.sleep(1)
driver.find_element_by_xpath(
'//*[@id="pane-1"]/div/div[2]/div[1]/div[2]/button[1]').click()#点击添加员工
time.sleep(1)