写的selenium自动化操作网页代码,用来在服务器输入数据。代码未整理。

服务器是vue antd开发的前端。

以调试方式打开edge浏览器

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9222  --user-data-dir="e:\selenum\ChromeProfile"
exit

 在浏览器中打开要操作的网页,然后运行python脚本自动化操作。

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import selenium
from urllib.parse import quote
import getpath
from pathlib import Path
import bq
import para
import codecs
import logging
options = webdriver.EdgeOptions()
# 加启动配置
# options = webdriver.ChromeOptions()
# 打开chrome浏览器
# 此步骤很重要,设置为开发者模式,防止被各大网站识别出来使用了Selenium
#options.add_experimental_option('excludeSwitches', ['enable-logging'])#禁止打印日志
# options.add_experimental_option('excludeSwitches', ['enable-automation'])#实现了规避监测
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222");
#options.add_experimental_option("excludeSwitches",['enable-automation','enable-logging'])#上面两个可以同时设置
# options.add_argument('--headless') # 无头模式
options.add_argument('--disable-gpu')  # 上面代码就是为了将Chrome不弹出界面
options.add_argument('--start-maximized')#最大化
# options.excludeSwitches('enable-logging');
# options.add_experimental_option('excludeSwitches', ['enable-logging'])
# options.add_argument('--incognito')#无痕隐身模式
# options.add_argument("disable-cache")#禁用缓存
options.add_argument('disable-infobars')
options.add_argument('log-level=3')#INFO = 0 WARNING = 1 LOG_ERROR = 2 LOG_FATAL = 3 default is 0

# options.add_experimental_option("detach", True)
# 使用Firefox浏览器

# desired_capabilities = chrome_options.to_capabilities()
# desired_capabilities['pageLoadStrategy'] = 'none'
# desired_capabilities['timeouts'] = {'implicit': 3000, 'pageLoad': 3000, 'script': 3000}
# driver = webdriver.Chrome(desired_capabilities=desired_capabilities)

driver = webdriver.Edge(options = options)
driver.implicitly_wait(5)
host="http://10.0.108.4:3000"
usr="mahongquan"
pwd="123456"
#group_name=["拉伸通用基础","拉伸通用项目"]
group_name=["24-原始记录-力学拉伸基本信息","24-原始记录-力学拉伸项目信息"]
# group_name=["ICP基础","ICP项目"]
# group_name=["通用基础","通用项目"]
item_at1=False
# group_name=["通用基础信息","通用项目信息"]

#文本框输入字符粗
def set_input(ele,value):
    ele.click()#点击这个文本框
    ele.send_keys(Keys.CONTROL+'a')#光标向右移方便删除
    ele.send_keys(Keys.BACKSPACE)#删除键
    ele.send_keys(value)
    ele.send_keys(Keys.ENTER)
def login_lims():
    driver.get(host)
    # 定位用户名输入框
    try:
        username = driver.find_element(By.ID,"username")
        username.send_keys(usr)
        # 定位密码输入框
        password = driver.find_element(By.ID,"password")
        password.send_keys(pwd)
        # 定位登录按钮并点击
        login_button = driver.find_element(By.CLASS_NAME,"login-button")
        login_button.click()
    except selenium.common.exceptions.NoSuchElementException:
        pass
def show_table(table):
    rs=table.find_elements(By.TAG_NAME,"tr")
    for one in rs:
        tds=one.find_elements(By.TAG_NAME,"td")
        one_data=[]
        for td in tds:
            one_data.append(td.text)
        print(one_data)
def get_table_cell(table,i,j):
    rs=table.find_elements(By.TAG_NAME,"tr")
    one=rs[i]
    tds=one.find_elements(By.TAG_NAME,"td")
    return tds[j]
def get_table_cell_text(table,i,j):
    rs=table.find_elements(By.TAG_NAME,"tr")
    one=rs[i]
    tds=one.find_elements(By.TAG_NAME,"td")
    return tds[j].text 
def find_table_row(table,col,t,col2,t2):
    rs=table.find_elements(By.TAG_NAME,"tr")
    i=0
    for one in rs:
        tds=one.find_elements(By.TAG_NAME,"td")
        j=0
        match=[False,False]
        for td in tds:
            print(td.text,t)
            if j==col:
                if t==td.text:
                    match[0]=True
            if j==col2:
                if t2==td.text:
                    match[1]=True
            if match[0] and match[1]:
                return i
            j+=1
        i+=1
    return None
def test_wait():
    driver.implicitly_wait(5)
    # 访问百度
    driver.get("http:#www.baidu.com")
    # 定位登录按钮并进行点击,在5s之内,找到元素,会立即点击
    try:
        driver.find_element(By.XPATH, '#*[@id="s-top-loginbtn"]').click()

        # 设置一个找不到的元素,会进行等待,等待5s后,依旧找不带,会抛出异常
        driver.find_element(By.XPATH,'#*[@id="s-top-loginbtn1"]').click()
    except selenium.common.exceptions.NoSuchElementException as e1:
        pass
def to_menu(menutxt):
    menu= driver.find_element(By.CLASS_NAME,"ant-menu")
    s=menu.find_elements(By.CLASS_NAME,"ant-menu-submenu")
    ActionChains(driver).move_to_element(s[4]).perform()#第四个菜单
    i=driver.find_elements(By.CLASS_NAME,"ant-menu-item")
    for one in i:
        if one.text==menutxt:
            one.click()
def tree_node(treetxt):
    t=driver.find_elements(By.CLASS_NAME,"ant-tree-node-content-wrapper")
    for one in t:
        if one.text==treetxt:#"原始记录单":
            one.click()
            break
def origin_cur_action(title,action):
    ts=driver.find_elements(By.CLASS_NAME,"ant-table-wrapper")
    ts=ts[0].find_elements(By.CLASS_NAME,"ant-table-fixed")
    left=ts[1]
    right=ts[3]
    rows=left.find_elements(By.CLASS_NAME,"ant-table-row")
    rows_right=right.find_elements(By.CLASS_NAME,"ant-table-row")
    for i in range(len(rows)):
        tds=rows[i].find_elements(By.TAG_NAME,"td")
        tds_right=rows_right[i].find_elements(By.TAG_NAME,"td")
        if len(tds)>1:
            if (tds[1].text==title):
                print(tds[1].text,tds_right[-1].text)
                tds_right[-1].find_element(By.LINK_TEXT,action).click()
                return True
    return False
def scroll():
    # h=document.getElementsByClassName("scroll")[0].scrollHeight # 获取滚动条高度
    # document.getElementsByClassName("scroll")[0].scrollWidth # 获取横向滚动条宽度
    js="""h=document.getElementsByClassName("ant-table-body")[0].scrollHeight;
    document.getElementsByClassName("ant-table-body-inner")[0].scrollTop=h/2;
    """
    # 就是这么简单,修改这个元素的scrollTop就可以
    # document.getElementsByClassName("scroll")[0].scrollLeft=xxx # 控制横向滚动条位置
    driver.execute_script(js)
    time.sleep(500)
def origin(title,action):#查找模板,打开绑定
    r=origin_cur_action(title,action)
    if not r:
        scroll()
        r=origin_cur_action(title,action)
def test_scroll():
    filename = os.path.abspath(os.path.join(".","scroll.html"))
    url = Path(filename).as_uri()
    driver.get(url)
    # h=document.getElementsByClassName("scroll")[0].scrollHeight # 获取滚动条高度
    # document.getElementsByClassName("scroll")[0].scrollWidth # 获取横向滚动条宽度
    js="""h=document.getElementsByClassName("scroll")[0].scrollHeight;
    document.getElementsByClassName("scroll")[0].scrollTop=h/2;
    """
    # 就是这么简单,修改这个元素的scrollTop就可以
    # document.getElementsByClassName("scroll")[0].scrollLeft=xxx # 控制横向滚动条位置
    driver.execute_script(js)
class LeftItem():
    def __init__(self,left):
        self.left=left
        items=left.find_elements(By.XPATH,"./ul/li/ul/li")
        self.i0=items[0]
        self.i1=items[1]
        print(self.i0,self.i1)
        self.state=(0,0)
    def nowState(self):
        self.state=[False,False]
        if "ant-tree-switcher_close" in self.i0.find_element(By.TAG_NAME,"span").get_attribute("class"):
            self.state[0]=False
        else:
            self.state[0]=True
        if "ant-tree-switcher_close" in self.i1.find_element(By.TAG_NAME,"span").get_attribute("class"):
            self.state[1]=False
        else:
            self.state[1]=True            
    def open(self,at):
        print(at)
        self.nowState()
        if at==0:
            if self.state[0]==True:
                return
            else:
                self.click_left_item(0)#open
        else:
            if self.state[0]==True:
                self.click_left_item(0)#close
                time.sleep(0.5) 
            if self.state[1]==True:
                pass
            else:
                self.click_left_item(1)#open
    def open_node(self,group,title):
        if group==1:
            x=self.i1.find_elements(By.XPATH,"./ul/li")
        else:
            x=self.i0.find_elements(By.XPATH,"./ul/li")
        for one in x:
            if one.text==title:
                one.find_elements(By.TAG_NAME,"span")[1].click()
    def open_group_item(self,group,item):
        print([group,item])
        self.open(group)
        time.sleep(0.5)
        self.open_node(group,item)   
    def click_left_item(self,item):#item=0 项目信息 item=1 基础信息
        items=self.left.find_element(By.TAG_NAME,"ul").find_element(By.TAG_NAME,"li").find_element(By.TAG_NAME,"ul").find_elements(By.TAG_NAME,"li")
        the=items[item]
        the.find_elements(By.TAG_NAME,"span")[0].click()    
    def click_left_title(self,item):#item=0 项目信息 item=1 基础信息
        items=self.left.find_element(By.TAG_NAME,"ul").find_element(By.TAG_NAME,"li").find_element(By.TAG_NAME,"ul").find_elements(By.TAG_NAME,"li")
        the=items[item]
        the.find_elements(By.TAG_NAME,"span")[1].click()    
    def tree_items(self,item):
        r=[]
        items=self.left.find_element(By.TAG_NAME,"ul").find_element(By.TAG_NAME,"li").find_element(By.TAG_NAME,"ul").find_elements(By.TAG_NAME,"li")
        the=items[item]#selenium.common.exceptions.NoSuchElementException
        if "</ul>" in the.get_attribute('innerHTML'):
            ls=the.find_element(By.TAG_NAME,"ul").find_elements(By.TAG_NAME,"li")
            for l in ls:
                r.append(l.text)
        return r
    def left_items(self,at):
        r=self.tree_items(at)
        if len(r)==0:
            self.click_left_item(at)
            r=self.tree_items(at)
        return r
    # def left_items2(self):
    #     r=self.tree_items(1)
    #     if len(r)==0:
    #         self.click_left_item(1)
    #         r=self.tree_items(1)
    #     print(r)
    #     return r                 
class Bq():
    def __init__(self):
        eles=driver.find_elements(By.CLASS_NAME,"bindTagContent")
        self.left=eles[0]
        self.right=eles[2]
        self.buttons=eles[3]
        self.leftitem=LeftItem(self.left)
    def show_right_check(self,item):#{#item=0 项目信息 item=1 基础信息
      if (self.right.text==""): #right panel is not show
         self.show_right(item)
      else:
        title=self.right_title()
        if(title==group_name[1]):
            print("now is item")
            if(item==0):#is shown
                print("pass")
            else:#show 通用基础信息
                self.show_right(item)
        elif (title==group_name[0]):
            print("now is base")
            if(item==0):#is shown
                self.show_right(item)
        else:
            print("now is none")
            self.show_right(item)
    def show_right(self,item):#item=0 项目信息 item=1 基础信息
        print("show right",item)
        if item_at1:
            if item==0:
                item=1
            else:
                item=0
        items=self.left.find_element(By.TAG_NAME,"ul").find_element(By.TAG_NAME,"li").find_element(By.TAG_NAME,"ul").find_elements(By.XPATH,"./li")
        the=items[item]
        the.find_elements(By.TAG_NAME,"span")[1].find_element(By.TAG_NAME,"span").click()
    def right_texts(self):
        r=[]
        if self.right.text=="":
            return r
        forms=self.right.find_elements(By.TAG_NAME,'form')
        i=0
        while(i<len(forms)):
            form=forms[i]
            print(form)
            div=form.find_element(By.TAG_NAME,'div')
            cols=div.find_elements(By.TAG_NAME,'div')
            span=cols[1].find_element(By.TAG_NAME,'div').find_element(By.TAG_NAME,'span')
            r.append((cols[0].text,span.text))
            i+=1
        return r
    def right_title(self):
        if self.right.text=="":
            return None
        forms=self.right.find_elements(By.TAG_NAME,'form')
        form=forms[0]
        print(form)
        div=form.find_element(By.TAG_NAME,'div')
        cols=div.find_elements(By.TAG_NAME,'div')
        span=cols[1].find_element(By.TAG_NAME,'div').find_element(By.TAG_NAME,'span')
        return span.find_element(By.TAG_NAME,'input').get_attribute('value')
    def show_bq(self):
        # print("here")
        # self.show_right_check(left,right,1);#通用基础信息
        # time.sleep(50);
        if self.right.text=="":
            return
        forms=self.right.find_elements(By.TAG_NAME,'form')
        i=0
        while(i<len(forms)):
            form=forms[i]  
            print(form)
            div=form.find_element(By.TAG_NAME,'div')
            cols=div.find_elements(By.TAG_NAME,'div')
            # if(i==1):
            print(i,cols[0].text,cols[1].text)
            i+=1
        #end while
         # forms[3].find_element(By.XPATH,"#div/div[2]/div/span/div/div").get_attribute("role")
    # def ant_select(self):
    #     # driver.switch_to.active_element.send_keys(Keys.ENTER)
    def bangdingGroup(self,dict0):
        print(dict0[0][1])
        if dict0[0][1]==group_name[1]:#
            self.show_right_check(0)
            time.sleep(0.1)
            self.forms=self.right.find_elements(By.TAG_NAME,'form')
            for one in dict0.keys():
                print("===================")
                print(one,dict0)
                if dict0[one][1]!="":
                    self.setGroupValue(one,dict0[one][1])
            self.buttons.find_elements(By.TAG_NAME,"button")[0].click()
            time.sleep(0.5)
        elif dict0[0][1]==group_name[0]:
            self.show_right_check(1)
            time.sleep(0.5)
            self.forms=self.right.find_elements(By.TAG_NAME,'form')
            for one in dict0.keys():
                if dict0[one][1]!="":
                    print(one,dict0)
                    self.setGroupValue(one,dict0[one][1])
                    time.sleep(0.5)
            self.buttons.find_elements(By.TAG_NAME,"button")[0].click()
            time.sleep(0.5)
    def setGroupValue(self,at,value):
        if at in [1,3,6,7,8]:
            combo=self.forms[at].find_element(By.XPATH,"./div/div[2]/div/span/div/div")#.get_attribute("role")
            combo.click() # 模拟鼠标点击
            time.sleep(0.5)
            eles=driver.find_elements(By.CLASS_NAME,"ant-select-dropdown-menu-item")
            for ele in eles:
                if ele.text==value:
                    ele.click() #at=3 图片,at=0 字符串
        elif at==0:
            pass
        else:
            if at<len(self.forms):
                ele=self.forms[at].find_element(By.XPATH,"./div/div[2]/div/span/span/input")#.send_keys("B2")
                ele.click()#点击这个文本框
                ele.send_keys(Keys.CONTROL+'a')#光标向右移方便删除
                ele.send_keys(Keys.BACKSPACE)#删除键
                ele.send_keys(value)            
    def bangdingItem(self,group,dict0):
        print([group,dict0])
        print(dict0[1])
        # self.leftitem.open_group_item(group,dict0[1][1])#use english name
        print("english",dict0[1][1])
        print("chinese",dict0[0][1])
        self.leftitem.open_group_item(group,dict0[0][1])#use chinese name 
        # input("here")
        # return 
        time.sleep(0.6)
        self.forms=self.right.find_elements(By.TAG_NAME,'form')
        for one in dict0.keys():
            if dict0[one][1]!="":
                print((one,dict0[one][1]))
                self.setItemValue(one,dict0[one][1])
        self.buttons.find_elements(By.TAG_NAME,"button")[0].click()
        time.sleep(0.5)
    def setItemValue(self,at,value):
        if at in [2,5,6,7,8]:
            combo=self.forms[at].find_element(By.XPATH,"./div/div[2]/div/span/div/div")#.get_attribute("role")
            combo.click() # 模拟鼠标点击
            time.sleep(0.5)
            eles=driver.find_elements(By.CLASS_NAME,"ant-select-dropdown-menu-item")
            for ele in eles:
                if ele.text==value:
                    ele.click() #at=3 图片,at=0 字符串
        elif at in [0,1]:
            pass
        else:
            ele=self.forms[at].find_element(By.XPATH,"./div/div[2]/div/span/span/input")#.send_keys("B2")
            ele.click()#点击这个文本框
            ele.send_keys(Keys.CONTROL+'a')#光标向右移方便删除
            ele.send_keys(Keys.BACKSPACE)#删除键
            ele.send_keys(value) 
def bindTag(moban_name):
    print("here")
    b=Bq()
    (d0,d1,d2)=bq.getBq(moban_name)#group,item,base
    for one in d0:
        b.bangdingGroup(one)
    print("bind item")
    for one in d1:#项目
        if item_at1:
            b.bangdingItem(1,one)
        else:
            b.bangdingItem(0,one)
    print("bind base")
    for one in d2:#基础
        if item_at1:
            b.bangdingItem(0,one)
        else:
            b.bangdingItem(1,one)
def to_bangding_bq():
    login_lims()
    to_menu("模板管理")
    tree_node("原始记录单")
    origin("拉伸","绑定")
def to_bangding_ff():
    tree_node("原始记录单")
    origin("拉伸","关联方法")
def to_origin():
    login_lims()
    to_menu("模板管理")
    tree_node("原始记录单")

def scroll_tree():
    js="""function _x(STR_XPATH) {
  var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
  var xnodes = [];
  var xres;
  while (xres = xresult.iterateNext()) {
      xnodes.push(xres);
  }
  return xnodes[0];
}
e=_x('#*[@id="app"]/div/div[2]/div[1]/div');
h=e.scrollHeight;
e.scrollTop=h;
"""
    driver.execute_script(js)

class Model_glff():
    def __init__(self):
        dlgs=driver.find_elements(By.CLASS_NAME,"ant-modal-body")
        self.root=None
        for dlg in dlgs:
            if "方法编号" in dlg.text:
                self.root=dlg
                break
        self.close_button=self.root.find_element(By.XPATH,"../button")
        # self.search_box=self.root.find_element(By.XPATH,"./div/div/div[2]")
        # self.ffbh=self.search_box.find_element(By.TAG_NAME,"input")
        # self.table=self.root.find_element(By.XPATH,"./div/div/div[1]")
        # self.col2=self.table.find_element(By.XPATH,"./div/div[2]")
        # self.table2=self.col2.find_element(By.CLASS_NAME,"ant-table-tbody")
        # self.query=self.search_box.find_element(By.XPATH,"./button")
        # self.queding=self.search_box.find_element(By.XPATH,"./button[2]")                
        # self.search_box=self.root.find_element(By.XPATH,"./div/div/div[1]")
        # self.ffbh=self.search_box.find_element(By.TAG_NAME,"input")
        # self.table2=self.root.find_element(By.XPATH,"./div/div/div[2]")
        # self.table2=self.table2.find_elements(By.TAG_NAME,"table")[1]
        # # self.col2=self.table.find_element(By.XPATH,"./div/div[2]")
        # # self.table2=self.col2.find_element(By.CLASS_NAME,"ant-table-tbody")
        # self.query=self.search_box.find_element(By.XPATH,"./button")
        # self.queding=self.search_box.find_element(By.XPATH,"./button[2]")
        self.search_box=self.root.find_element(By.XPATH,"./div/div/div[1]")
        self.ffbh=self.search_box.find_element(By.TAG_NAME,"input")
        self.table=self.root.find_element(By.XPATH,"./div/div/div[2]")#'hanson-table'
        self.col2=self.table.find_element(By.XPATH,"./div/div/div/div[1]")#ant-table
        self.table2=self.col2.find_element(By.XPATH,"./div/div/div[2]")#ant-table-body
        # self.table2=self.col2.find_element(By.CLASS_NAME,"ant-table-tbody")
        self.query=self.search_box.find_element(By.XPATH,"./button")
        self.queding=self.search_box.find_element(By.XPATH,"./button[2]")
    def selectRow0(self):
        rs=self.table2.find_elements(By.TAG_NAME,"tr")
        rs[0].find_element(By.TAG_NAME,"input").click()
    def selectRow(self,row):
        rs=self.table2.find_elements(By.TAG_NAME,"tr")
        rs[row].find_element(By.TAG_NAME,"input").click()
    def selectEjff(self,ejff,ff):
        row=find_table_row(self.table2,4,ejff,2,ff)#column ejff=4
        if row!=None:
            self.selectRow(row)
            return True
        else:
            return False
    def search(self,ff):
        (ff,ejff)=ff
        self.ffbh.click()#点击这个文本框
        self.ffbh.send_keys(Keys.CONTROL+'a')#光标向右移方便删除
        self.ffbh.send_keys(Keys.BACKSPACE)#删除键
        self.ffbh.send_keys(ff)
        self.query.click()
        time.sleep(.5)
        # self.selectRow0()
        if self.selectEjff(ejff,ff):
            self.queding.click()
            time.sleep(.5)
        else:
            self.close_button.click()
def bangding_ffs(moban_name):
    ffs=codecs.open("ffs.csv",encoding="utf-8").readlines()
    ffs=[ff[:-2].split("\t") for ff in ffs]
    # moban_name="ICP-MS"
    # ffs=ffs.split("\n")
    i=0;
    print(len(ffs))
    while(i<len(ffs)):
        print(i,ffs[i]);
        bangding_ff_one(moban_name,ffs[i]);
        i+=1;
        # if(i==2):
        #     break;
def bangding_ff_one(moban_name,ff):
    origin(moban_name,"关联方法");
    time.sleep(1)
    m=Model_glff()
    m.search(ff)
def add_args(moban_name):
    print("begin");
    paras=para.getPara(moban_name)
    print(paras);
    i=0;
    while(i<len(paras)):
      add_dict(paras[i])
      print(paras[i])
      i+=1;
def add_dict(ff):
    print("add para===============");
    guanlian=driver.find_element(By.CSS_SELECTOR,"div.ant-row:nth-child(1) > div:nth-child(2) > div:nth-child(1) > button:nth-child(1)")
    # guanlian=_x("/html/body/div[1]/section/section/main/div[2]/div/div/div/div/div/div[1]/div[2]/div/button")
    print("添加",guanlian)
    guanlian.click()
    # ffbh=_x("/html/body/div[10]/div/div[2]/div/div[2]/div[2]/div/div/div[2]/div[1]/div[2]/input")
    time.sleep(.600)
    # ffbh=document.querySelector(".has-error > span:nth-child(1) > span:nth-child(1) > input:nth-child(1)")
    # ("html body.hanson div div.ant-modal-root div.ant-modal-wrap div.ant-modal div.ant-modal-content div.ant-modal-body form.ant-form.ant-form-horizontal div.ant-row.ant-form-item.ant-form-item-with-help div.ant-col.ant-col-18.ant-form-item-control-wrapper div.ant-form-item-control.has-error span.ant-form-item-children span.ant-input-affix-wrapper input.ant-input")
    # ffbh=_x("/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[1]/div[2]/div/span/span/input")
    #基础
    # ffbh=_x("/html/body/div[5]/div/div[2]/div/div[2]/div[2]/form/div[1]/div[2]/div/span/span/input")
    #error here
    divs=driver.find_elements(By.XPATH,"/html/body/div/div")
    find=False
    modal=None
    for sub in divs:
        if sub.get_attribute("class")=="ant-modal-root":
            modal=sub
            find=True
            break
    print(modal)
    if modal is None:
        return
    print(modal.get_attribute("class"))
    name=modal.find_element(By.XPATH,"./div[2]/div/div[2]/div[2]/form/div[1]/div[2]/div/span/span/input")
    print("名称",name,name.get_attribute("class"))
    set_input(name,ff[0])
    # delay(200);
    time.sleep(.500)
    name_en=modal.find_element(By.XPATH,"./div[2]/div/div[2]/div[2]/form/div[2]/div[2]/div/span/span/input")
    # query=driver.find_element(By.CSS_SELECTOR,"div.ant-form-item:nth-child(2) > div:nth-child(2) > div:nth-child(1) > span:nth-child(1) > span:nth-child(1) > input:nth-child(1)")
    print("英文名称",name_en)
    set_input(name_en,ff[1])
    # delay(200);
    time.sleep(.500)
    queding=modal.find_element(By.CSS_SELECTOR,".ant-btn-primary")
    queding.click();
    time.sleep(.500);
def add_dicts(moban_name):
    print("begin");
    paras=para.getDict(moban_name)
    print(paras);
    i=0;
    while(i<len(paras)):
      add_dict(paras[i])
      print(paras[i])
      i+=1;
def add_paras_ls():
    dicts=["sytemp","yplx","temp1","temp2","temp3",'yszj','ysbj','dhbj','dhzj1'
    ,'dhzj2','bz','dlwz','zdl','xqfl','sqfl']
    dicts+=["TEST_VALUES1","TEST_VALUES0","TEST_VALUES","HI","HK","code","SAMPLE_NAME","SAMPLE_CODE","ITEM_NAME"]
    for d in dicts:
        add_dict((d,d))
def add_dicts_ls():
    dicts=["sbbh","hth","sbxh","ysjbh","sygg","lssl1","lssl2","hjwd","hjsd","pxcd"]
    dicts+=["EQUIP_CODE","USER_NAME_FILE","AUDIT_USER_NAME_FILE","METHOD_CODE"]
    for d in dicts:
        add_dict((d,d))        
class Lims():
    def __init__(self):
        pass
    def to_origin(self):
        to_origin()
if __name__=="__main__":
    # from logging.handlers import RotatingFileHandler
    import sys
    # sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
    # sys.stderr = open(sys.stderr.fileno(), mode='w', encoding='utf8', buffering=1)
    # handlers=[RotatingFileHandler(filename="report.log", maxBytes=10*1024*1024, encoding='utf-8',backupCount=3),logging.StreamHandler(sys.stdout)]
    # logging.basicConfig(level=logging.DEBUG,
    #                     format = '%(asctime)s - %(name)s - %(levelname)s -%(funcName)s - %(message)s',
    #                     handlers=handlers)
    # print('begin')
    # getBq()
    # add_dicts("国标室温棒材拉伸")
    # to_origin()
    # add_args("国标室温棒材拉伸")
    # bangding_ffs("拉伸")
    bindTag("新国标室温棒材拉伸")

Logo

一站式 AI 云服务平台

更多推荐