How to use nth method in Playwright Python

Best Python code snippet using playwright-python

price_base.py

Source:price_base.py Github

copy

Full Screen

1import time2from SRC.param.unitls_table import row_size3#新增商品、客户调价单按钮4def add_gc_modify_price_button(driver):5 driver.find_element_by_css_selector('div.row.space10 > div.text-right > a:nth-child(1)').click()6#点击选择商品或客户图标7def select_gc_img(driver,index):8 time.sleep(3)9 driver.find_element_by_css_selector('tbody > tr:last-child > td:nth-child('+str(index)+') > a > span').click()10#搜索客户或商品11def search_gc(driver,name):12 time.sleep(3)13 # 在搜索框中输入商品名称14 driver.find_element_by_css_selector('#exampleInputAmount').send_keys(name)15 # 点击搜索按钮16 driver.find_element_by_css_selector('i.glyphicon.glyphicon-search').click()17 time.sleep(2)18#选择客户或客户级别19def select_customer_jb(driver,c_name):20 search_gc(driver,c_name)21 #统计客户个数22 count_tr=row_size(driver,'div.row.space20 > div > table > tbody>tr')23 for i in range(0,int(count_tr)):24 if driver.find_element_by_css_selector('div.row.space20 > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(3)').text==c_name:25 #选择客户26 driver.find_element_by_css_selector('div.row.space20 > div > table > tbody > tr:nth-child('+str(i+1)+') > td.text-center > input').click()27 break28 time.sleep(2)29 # 点击确定30 ok_button(driver)31 time.sleep(2)32#选择商品33def select_goods(driver,goods_name,sku):34 search_gc(driver,goods_name)35 # 统计商品个数36 count_tr = row_size(driver, 'div.col-xs-10 > div:nth-child(2) > table > tbody>tr')37 for i in range(0, int(count_tr)):38 if driver.find_element_by_css_selector('table > tbody > tr:nth-child(' + str(39 i + 1) + ') > td.wordBreak.ng-binding').text == goods_name:40 # 选择商品41 driver.find_element_by_css_selector(42 'tbody > tr:nth-child(' + str(i + 1) + ') > td.wordBreak.ng-binding').click()43 break44 time.sleep(2)45 # 商品属性46 if sku != '无':47 sku_list = sku.split('+')48 # 获取属性个数49 count_property = row_size(driver, 'div.col-xs-12.propertyPop.space15>dl')50 for i in range(0, int(count_property)):51 count_property_value = row_size(driver, 'div.col-xs-12.propertyPop.space15 > dl:nth-child(' + str(52 i + 1) + ') > dd > a')53 for j in range(0, int(count_property_value)):54 for m in range(len(sku_list)):55 if driver.find_element_by_css_selector('div.col-xs-12.propertyPop.space15 > dl:nth-child(' + str(56 i + 1) + ') > dd > a:nth-child(' + str(j + 1) + ')').text == sku_list[m]:57 driver.find_element_by_css_selector('div.col-xs-12.propertyPop.space15 > dl:nth-child(' + str(58 i + 1) + ') > dd > a:nth-child(' + str(j + 1) + ')').click()59 break60 # 点击确定61 ok_button(driver)62#确定按钮63def ok_button(driver):64 # 点击确定65 driver.find_element_by_css_selector('button.btn.btn-save.btn-warning').click()66#数量下限按钮67def limit_num_button(driver,td):68 time.sleep(2)69 driver.find_element_by_css_selector('tbody > tr:nth-child(1) > td:nth-child('+str(td)+') > a > span').click()70#添加数量下限71def limit_num(driver,limitnum,price):72 time.sleep(2)73 driver.find_element_by_css_selector('tbody > tr:nth-child(1) > td:nth-child(1) > input').clear()74 driver.find_element_by_css_selector('tbody > tr:nth-child(1) > td:nth-child(1) > input').send_keys(str(limitnum))75 time.sleep(2)76 #添加价格77 driver.find_element_by_css_selector('tbody > tr:nth-child(1) > td:nth-child(2) > input').clear()78 driver.find_element_by_css_selector('tbody > tr:nth-child(1) > td:nth-child(2) > input').send_keys(str(price))79 time.sleep(2)80 #点击确定81 ok_button(driver)82#保存返回列表并点击整单生效83def order_list_zdsx(driver,tag):84 time.sleep(2)85 driver.find_element_by_css_selector('button.btn.btn-lg.btn-warning.m-l-20.ng-scope').click()86 time.sleep(3)87 #点击返回按钮88 driver.find_element_by_css_selector('a.btn.btn-default.pull-left.btn-sm ').click()89 time.sleep(2)90 if tag!='sp':91 #点击整单生效92 choose_price_dimension(driver,tag)93 time.sleep(1)94 #点击查询95 driver.find_element_by_css_selector('div.text-right > button').click()96 time.sleep(2)97 driver.find_element_by_css_selector('#secondtable > tbody > tr:nth-child(1) > td > a.btn.btn-default.btn-sm.ng-scope').click()98#点击进入订货/企业端按钮99def switch_to_dh(driver):100 driver.find_element_by_css_selector('div.pull-right.m-l-20.enter-companys-d > div').click()101def switch_to_qy(driver):102 driver.find_element_by_css_selector("div.pull-right.m-l-20.enter-companys-d.ng-scope > a > span").click()103#选择日期104def choose_date(driver,s_td,e_td,start,end):105 js='$("tbody > tr > td:nth-child('+str(s_td)+') > p > input").removeAttr("readonly")'106 driver.execute_script(js)107 driver.find_element_by_css_selector('tbody > tr > td:nth-child('+str(s_td)+') > p > input').send_keys(start)108 #选择终止日期109 js='$("tbody > tr > td:nth-child('+str(e_td)+') > p > input").removeAttr("readonly")'110 driver.execute_script(js)111 driver.find_element_by_css_selector('tbody > tr > td:nth-child('+str(e_td)+') > p > input').send_keys(end)112#选择定价维度113def price_dimension(driver,index):114 time.sleep(2)115 driver.find_element_by_css_selector('div.col-xs-11.orderList_form > a:nth-child('+str(index)+')').click()116 #点击确定117 driver.find_element_by_css_selector('button.btn.btn-primary.btn-save').click()118 time.sleep(2)119#选择定价维度--查询120def choose_price_dimension(driver,tag):121 driver.find_element_by_css_selector('form > div:nth-child(2) > div:nth-child(4) > select').click()122 if tag=='fl':123 driver.find_element_by_css_selector('form > div:nth-child(2) > div:nth-child(4) > select>option[label="客户分类"]').click()124 elif tag=='jb':125 driver.find_element_by_css_selector('form > div:nth-child(2) > div:nth-child(4) > select>option[label="客户级别"]').click()126 elif tag=='qy':127 driver.find_element_by_css_selector('form > div:nth-child(2) > div:nth-child(4) > select>option[label="区域"]').click()128 else:129 driver.find_element_by_css_selector('form > div:nth-child(2) > div:nth-child(4) > select>option[label="客户"]').click()130#选择客户分类或客户区域131def select_fl_qy_spfl(driver,td,li,name):132 time.sleep(2)133 driver.find_element_by_css_selector('table > tbody > tr > td:nth-child('+str(td)+')>div>div.col-xs-12.upDropDownTree > div > input').click()134 count_li=row_size(driver,li)135 for i in range(0,int(count_li)):136 li_text=driver.find_element_by_css_selector('table > tbody > tr > td:nth-child('+str(td)+')>div>div.col-xs-12.upDropDownTree > div > ul > li:nth-child('+str(i+1)+') > div > span.itemtxt.ng-binding').text137 if li_text==name:138 driver.find_element_by_css_selector('table > tbody > tr > td:nth-child('+str(td)+')>div>div.col-xs-12.upDropDownTree > div > ul > li:nth-child('+str(i+1)+') > div > span.itemtxt.ng-binding').click()139 break140#选择相应的客户、客户分类、区域、级别进入订货端141def select_fl_qy_jb(driver,tag,name):142 count_page=row_size(driver,'div.modal-body.modal-body-top > div:nth-child(3) > div > nav> ul> li')143 for j in range(0,int(count_page)-4):144 count_tr = row_size(driver, 'div.row.space20.select-item > div > table > tbody > tr')145 temp=''146 for i in range(0,int(count_tr)):147 if tag=='fl':148 td_text=driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(4)').text149 if td_text==name:150 driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(4)').click()151 temp=td_text152 break153 elif tag=='qy':154 td_text=driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(3)').text155 if td_text==name:156 driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(3)').click()157 temp = td_text158 break159 elif tag == 'jb':160 td_text=driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(5)').text161 if td_text==name:162 driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(5)').click()163 temp = td_text164 break165 else:166 td_text=driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(2)').text167 if td_text==name:168 driver.find_element_by_css_selector('div.row.space20.select-item > div > table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(2)').click()169 temp = td_text170 break171 if int(count_page)-4==1:172 break173 else:174 if temp==name:175 break176 else:177 driver.find_element_by_css_selector('div.modal-body.modal-body-top > div:nth-child(3) > div > nav > ul > li:nth-child(5) > a').click()178#客户折扣定价维度179def khzk_price_dimension(driver,index):180 time.sleep(2)181 driver.find_element_by_css_selector('div[ng-controller="customerdisrate"] > div:nth-child(2) > div.col-xs-4.orderList_form > a:nth-child('+str(index)+')').click()182#折扣类型183def khzk_type(driver,index):184 time.sleep(1)185 driver.find_element_by_css_selector('div[ng-controller="customerdisrate"] > div:nth-child(3) > div.col-xs-4.orderList_form > a:nth-child('+str(index)+')').click()186#新增折扣按钮187def add_zk_button(driver):188 time.sleep(1)189 driver.find_element_by_css_selector('a.btn.btn-warning.colorfff').click()190#折扣保存状态191def zk_save_status(driver,index):192 time.sleep(1)193 driver.find_element_by_css_selector('table > tbody > tr:last-child > td.ng-scope > a:nth-child('+str(index)+')').click()194 if index==3:195 driver.find_element_by_css_selector('button.btn.btn-primary.btn-save').click()196#输入折扣率197def input_zkl(driver,zkl,td):198 time.sleep(2)199 driver.find_element_by_css_selector('table > tbody > tr:last-child > td:nth-child('+str(td)+') > input').send_keys(str(float(zkl)*100))200#判断商品价格表中是否存在此变价单201def check_googs_single_valence(driver,goods_name,sx,slxx,jg,sxrq):202 time.sleep(1)203 result='false'204 driver.find_element_by_css_selector('form > div:nth-child(1) > div:nth-child(4) > input').send_keys(goods_name)205 #点击搜索206 driver.find_element_by_css_selector('form > div:nth-child(3) > div.text-right > button').click()207 count=row_size(driver,'ul.pagination>li')208 count_row=row_size(driver,'#firsttable > tbody > tr')209 count_page=int(count)-4210 for i in range(0,count_page):211 for j in range(0,count_row):212 table_sx=''213 count_sx=row_size(driver,'#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td.wProductPro.ng-scope > span > upmark')214 for m in range(0,int(count_sx)):215 temp=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td.wProductPro.ng-scope > span:nth-child('+str(m+1)+') > upmark','findAssert').text216 if m==0:217 table_sx = ''.join(temp.split(':')[1:])218 else:219 table_sx=table_sx+'+'+''.join(temp.split(':')[1:])220 table_slxx=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(3)').text221 table_jg=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(4)').text222 table_sxrq=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(5)').text223 if table_sx==sx and table_slxx==slxx and table_jg==jg and table_sxrq==sxrq :224 result='true'225 break226 if count_page==1:227 break228 else:229 if result=='true':230 break231 else:232 driver.find_element_by_css_selector('div.row.space20 > div > div.col-xs-12 > nav > ul > li:nth-child(5) > a > span').click()233 return result234#获取客户价格表中是否存在此变价单235def check_customer_single_valence(driver,tag,c_name,g_name,sx,slxx,jg,sxrq):236 time.sleep(1)237 result = 'false'238 choose_price_dimension(driver, tag)239 #输入商品名称240 driver.find_element_by_css_selector('input[ng-model="proNameOrCode"]').send_keys(g_name)241 #选择客户、客户分类、客户级别、区域242 driver.find_element_by_css_selector('button[ng-click="selectAgents()"]').click()243 search_gc(driver, c_name)244 choose_customer_sx(driver, c_name, tag)245 ok_button(driver)246 #点击搜索247 driver.find_element_by_css_selector('button[ng-click="search()"]').click()248 count=row_size(driver,'ul.pagination>li')249 count_row=row_size(driver,'#firsttable > tbody> tr')250 count_page=int(count)-4251 for i in range(0,count_page):252 for j in range(0,count_row):253 table_sx = '无'254 count_sx=row_size(driver,'#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td.wProductPro.ng-scope > span > upmark')255 for m in range(0,int(count_sx)):256 temp=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td.wProductPro.ng-scope > span:nth-child('+str(m+1)+') > upmark','findAssert').text257 if m==0:258 table_sx = ''.join(temp.split(':')[1:])259 else:260 table_sx=table_sx+'+'+''.join(temp.split(':')[1:])261 table_slxx=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(4)').text262 table_jg=driver.find_element_by_css_selector('#firsttable> tbody > tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(5)').text263 table_sxrq=driver.find_element_by_css_selector('#firsttable > tbody> tr:nth-child('+str(j+1)+') > td.no-border.p-0 > table > tbody > tr > td:nth-child(6)').text264 if table_sx==sx and table_slxx==slxx and table_jg==jg and table_sxrq==sxrq :265 result='true'266 break267 if count_page==1:268 break269 else:270 if result=='true':271 break272 else:273 driver.find_element_by_css_selector('div.row.space20 > div > div.col-xs-12 > nav > ul > li.next.disabled > a > span').click()274 return result275#获取客户折扣设置表中是否存在此记录ctag=1客户 2客户分类 3客户级别 4客户区域 gtag=1 商品分类 2商品276def check_customer_discount_price(driver,customer,goods,sx,ctag,gtag):277 result = 'false'278 if ctag==1:279 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(1) > div > input').clear()280 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(1) > div > input').send_keys(customer)281 elif ctag==2:282 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(3) > div > input').clear()283 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(3) > div > input').send_keys(customer)284 elif ctag==3:285 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(4) > div > input').clear()286 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(4) > div > input').send_keys(customer)287 elif ctag==4:288 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(2) > div > input').clear()289 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(2) > div > input').send_keys(customer)290 if gtag==1:291 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(5) > div > input').clear()292 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(5) > div > input').send_keys(goods)293 elif gtag==2:294 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(6) > div > input').clear()295 driver.find_element_by_css_selector('div.col-xs-10.corp-content.printlayout > div:nth-child(4) > div:nth-child(4) > div:nth-child(6) > div > input').send_keys(goods)296 #点击查询297 driver.find_element_by_css_selector('div.form-group.text-right.col-xs-2 > button').click()298 count=row_size(driver,'table > tbody > tr')299 if int(count)>0:300 if sx=='':301 result = 'true'302 else:303 for i in range(0,int(count)):304 table_sx = '无'305 table_temp=driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(i+1)+') > td:nth-child(5) > span').text306 if table_temp!='':307 temp_sx=table_temp.split(';')308 count_sx=len(temp_sx)309 for i in range(0,count_sx):310 if i==0:311 table_sx=''.join(temp_sx[i].split(':')[1:])312 else:313 table_sx = table_sx + '+' + ''.join(temp_sx[i].split(':')[1:])314 if table_sx==sx:315 result = 'true'316 break317 return result318#选择客户、客户分类、客户级别、区域319def choose_customer_sx(driver,name,tag):320 temp_name=''321 if tag=='kh' or tag=='jb':322 count_page=row_size(driver,'div.modal-body > div:nth-child(3) > div > nav > ul>li')323 count_row=row_size(driver,'div.modal-body > div.row.space20 > div > table > tbody > tr')324 elif tag=='fl':325 count_page=row_size(driver,'div.modal-body > div > div.col-xs-9 > div:nth-child(3) > div > nav > ul>li')326 count_row=row_size(driver,'div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr')327 else:328 count_page=row_size(driver,'div.modal-body > div > div.col-xs-9 > div:nth-child(3) > div > div > nav > ul>li')329 count_row=row_size(driver,'div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr')330 for i in range(0,int(count_page)-4):331 for j in range(0,int(count_row)):332 if tag == 'kh' or tag == 'jb':333 text_name=driver.find_element_by_css_selector('div.modal-body > div.row.space20 > div > table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2)').text334 if text_name==name:335 driver.find_element_by_css_selector('div.modal-body > div.row.space20 > div > table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2)').click()336 temp_name=text_name337 break338 elif tag=='fl':339 text_name = driver.find_element_by_css_selector(340 'div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr:nth-child(' + str(341 j + 1) + ') > td:nth-child(2)').text342 if text_name == name:343 driver.find_element_by_css_selector(344 'div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr:nth-child(' + str(345 j + 1) + ') > td:nth-child(2)').click()346 temp_name = text_name347 break348 else:349 text_name = driver.find_element_by_css_selector('div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2)').text350 if text_name == name:351 driver.find_element_by_css_selector('div.modal-body > div > div.col-xs-9 > div:nth-child(2) > div > table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2)').click()352 temp_name = text_name353 break354 if int(count_page)-4==1:355 break356 else:357 if temp_name==name:358 break359 else:...

Full Screen

Full Screen

yls_rule_operator_base.py

Source:yls_rule_operator_base.py Github

copy

Full Screen

1# coding=utf-82from SRC.param.yls_navigation_base import jigoudangan_navigation3from SRC.param.yls_base import get_successful_toast,choose_around_store4import time5######################################角色##########################################6# 进入角色界面7def log_role(driver):8 jigoudangan_navigation(driver ,'i.iconfont.icon-jichushezhi')9 # 点击角色10 driver.find_element_by_css_selector(11 'ul.ant-menu.ant-menu-vertical.ant-menu-light.ant-menu-root>li:nth-child(9)>ul>li:nth-child(1)>ul>li:nth-child(2)').click()12def add_role_button(driver):13 # 点击新增按钮14 driver.find_element_by_id('sys_rolelist|btnAdd').click()15# 角色信息16def role_info(driver ,code ,name):17 # 角色编码18 driver.find_element_by_css_selector('div.roleBody > div:nth-child(1) > div.col-float.width-400 > input').clear()19 driver.find_element_by_css_selector('div.roleBody > div:nth-child(1) > div.col-float.width-400 > input').send_keys \20 (code)21 # 角色名称22 driver.find_element_by_css_selector('div.roleBody > div:nth-child(2) > div.col-float.width-400 > input').clear()23 driver.find_element_by_css_selector('div.roleBody > div:nth-child(2) > div.col-float.width-400 > input').send_keys \24 (name)25def save_role_button(driver,save_btn):26 driver.find_element_by_css_selector(save_btn).click()27 return get_successful_toast(driver)28#添加功能权限29def add_functional_permissions(driver,first,second,third=0):30 target = driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div:nth-child('+str(first+1)+')> div:nth-child(2) > div:nth-child('+str(second)+')> div.second-auth > label > span.ant-checkbox > input')31 driver.execute_script("arguments[0].scrollIntoView();", target)32 if third==0:33 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div:nth-child('+str(first+1)+')> div:nth-child(2) > div:nth-child('+str(second)+')> div.second-auth > label > span.ant-checkbox > input').click()34 else:35 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div:nth-child('+str(first+1)+')> div:nth-child(2) > div:nth-child('+str(second)+')> div.last-auth > label:nth-child('+str(third)+') > span.ant-checkbox > input').click()36#切换权限页签37def switch_function_xczk(driver,tab):38 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.role-tabs.clearfix > div.tabs-control > div:nth-child('+str(tab)+')').click()39#添加现场折扣权限40def add_xczk(driver,flname,hyzk,zkl):41 #点击新增行42 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.role-tabs.clearfix > div.tabs-button > button > span').click()43 #获取行号44 xh=driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:last-child > div > div > div:nth-child(1) > div > div > div > div > div > div').text45 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(1) > div > div > div > div > div').click()46 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(1) > div > div > div > div > div > div > span > span > span.ant-select-arrow').click()47 element=driver.find_elements_by_css_selector('div.ant-popover-inner > div > div > div > ul > li> span:nth-child(3)')48 for ele in element:49 if element.index(ele)%8==0:50 target = driver.find_element_by_css_selector("div.ant-popover-inner > div > div > div > ul > li:nth-child("+str(element.index(ele)+1)+")> span.ant-tree-checkbox > span")51 driver.execute_script("arguments[0].scrollIntoView();", target)52 if ele.get_attribute("title")==flname:53 driver.find_element_by_css_selector('div.ant-popover-inner > div > div > div > ul > li:nth-child('+str(element.index(ele)+1)+') > span.ant-tree-checkbox > span').click()54 break55 #点击确定56 driver.find_element_by_css_selector('button.ant-btn.ant-btn.ant-btn-primary.ant-btn-sm.lf-margin').click()57 #已执行会员折扣58 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(2) > div > div > div > div > div').click()59 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(2) > div > div > div > div > div > div > div.ant-select.ant-select-enabled > div > span').click()60 for i in range(0,2):61 if driver.find_element_by_css_selector('ul.ant-select-dropdown-menu.ant-select-dropdown-menu-vertical.ant-select-dropdown-menu-root>li:nth-child('+str(i+1)+')').text==hyzk:62 driver.find_element_by_css_selector('ul.ant-select-dropdown-menu.ant-select-dropdown-menu-vertical.ant-select-dropdown-menu-root>li:nth-child('+str(i+1)+')').click()63 #折扣率下限64 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div > div').click()65 #driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child(' + xh + ') > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div > div > div > div.ant-input-number > div.ant-input-number-input-wrap > input').clear()66 driver.find_element_by_css_selector('div.ant-row.roleRow.function-limit > div > div.meta-table.listTable > div:nth-child(1) > div > div > div:nth-child(3) > div:nth-child('+xh+') > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div > div > div > div.ant-input-number > div.ant-input-number-input-wrap > input').send_keys(zkl)67#####################################操作员##########################################68# 进入操作员界面69def log_operator(driver):70 jigoudangan_navigation(driver, 'i.iconfont.icon-jichushezhi')71 # 点击操作员72 driver.find_element_by_css_selector(73 'ul.ant-menu.ant-menu-vertical.ant-menu-light.ant-menu-root>li:nth-child(9)>ul>li:nth-child(1)>ul>li:nth-child(1)').click()74def add_oper_button(driver):75 # 点击新增按钮76 driver.find_element_by_id('aa_userlist|btnAdd').click()77# 操作员信息78def operator_info(driver, zh, name, mail, tel):79 count = len(driver.find_elements_by_css_selector(80 'div.uretail-right-content.ant-layout-content>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(2)>div>div>div.ant-row'))81 if count == 2:82 element = driver.find_elements_by_css_selector('div.ant-row.group-container>div>div>div:nth-child(2)>div>div')83 for ele in element:84 if ele.get_attribute("id") == 'aa_user|code':85 user_code(driver, zh)86 if ele.get_attribute("id") == 'aa_user|name':87 user_name(driver, name)88 if ele.get_attribute("id") == 'aa_user|email':89 user_email(driver, mail)90 if ele.get_attribute("id") == 'aa_user|mobile':91 user_mobile(driver, tel)92# 账号93def user_code(driver, zh):94 driver.find_element_by_css_selector(95 'div[id="aa_user|code"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()96 driver.find_element_by_css_selector(97 'div[id="aa_user|code"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()98 driver.find_element_by_css_selector(99 'div[id="aa_user|code"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').send_keys(100 zh)101# 姓名102def user_name(driver, name):103 driver.find_element_by_css_selector(104 'div[id="aa_user|name"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()105 driver.find_element_by_css_selector(106 'div[id="aa_user|name"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()107 driver.find_element_by_css_selector(108 'div[id="aa_user|name"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').send_keys(109 name)110# 邮箱111def user_email(driver, mail):112 driver.find_element_by_css_selector(113 'div[id="aa_user|email"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()114 driver.find_element_by_css_selector(115 'div[id="aa_user|email"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').send_keys(116 mail)117# 手机号118def user_mobile(driver, tel):119 driver.find_element_by_css_selector(120 'div[id="aa_user|mobile"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()121 driver.find_element_by_css_selector(122 'div[id="aa_user|mobile"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').clear()123 driver.find_element_by_css_selector(124 'div[id="aa_user|mobile"] > div > div.ant-row > div.col-float.input-control.control-width > span > input').send_keys(125 tel)126# 增行按钮127def add_oper_role_button(driver):128 driver.find_element_by_id('aa_user|btnAddRow_role').click()129def add_organ_button(driver):130 driver.find_element_by_id('aa_user|btnAddRow_org').click()131def add_store_role_button(driver):132 driver.find_element_by_id('aa_user|btnAddRow_store').click()133# 添加角色134def add_role(driver):135 element = driver.find_elements_by_css_selector(136 'div[id="aa_user|aa_usertabrole"]>div>div.meta-table.listTable>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div>div')137 for ele in element:138 if ele.get_attribute("id") == 'aa_user|aa_userrole|role_name':139 col = element.index(ele)140 driver.find_element_by_css_selector(141 'div[id="aa_user|aa_usertabrole"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(142 col + 1) + ')>div>div>div>div>div').click()143 driver.find_element_by_css_selector(144 'div[id="aa_user|aa_usertabrole"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(145 col + 1) + ')>div>div>div>div>div>div>div:nth-child(1)>div>div>span>span>div>i.anticon.anticon-canzhao').click()146 choose_around_store(driver)147def add_role1(driver,role_name):148 element = driver.find_elements_by_css_selector(149 'div[id="aa_user|aa_usertabrole"]>div>div.meta-table.listTable>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div>div')150 for ele in element:151 if ele.get_attribute("id") == 'aa_user|aa_userrole|role_name':152 col = element.index(ele)153 driver.find_element_by_css_selector(154 'div[id="aa_user|aa_usertabrole"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(155 col + 1) + ')>div>div>div>div>div').click()156 driver.find_element_by_css_selector(157 'div[id="aa_user|aa_usertabrole"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(158 col + 1) + ')>div>div>div>div>div>div>div:nth-child(1)>div>div>span>span>div>i.anticon.anticon-canzhao').click()159 choose_role(driver,role_name)160def choose_role(driver,role_name):161 #搜索角色162 driver.find_element_by_css_selector('div.ant-modal-body > div > div > div:nth-child(1) > div > div:nth-child(1) > span > input').clear()163 driver.find_element_by_css_selector('div.ant-modal-body > div > div > div:nth-child(1) > div > div:nth-child(1) > span > input').send_keys(role_name)164 driver.find_element_by_css_selector('div.ant-modal-body > div > div > div:nth-child(1) > div > div:nth-child(1) > span > span > i').click()165 # 选择第一个门店166 time.sleep(2)167 driver.find_element_by_css_selector(168 'div.ant-modal-body > div > div > div:nth-child(2) > div > div:nth-child(1) > div.fixedDataTableLayout_main.public_fixedDataTable_main > div > div:nth-child(3) > div:nth-child(1) > div > div > div:nth-child(1) > div > div > div > div > div > div > div > label > span > input').click()169 time.sleep(2)170 driver.find_element_by_css_selector(171 'div.ant-modal-content > div.ant-modal-footer > button.ant-btn.ant-btn-primary.ant-btn-lg').click()172# 添加门店权限173def add_store_role(driver):174 element = driver.find_elements_by_css_selector(175 'div[id="aa_user|aa_user_tab_store"]>div>div.meta-table.listTable>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div:nth-child(2)>div>div>div>div')176 for ele in element:177 if ele.get_attribute("id") == 'aa_user|aa_userstore|store_name':178 col = element.index(ele)179 driver.find_element_by_css_selector(180 'div[id="aa_user|aa_user_tab_store"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(181 col + 1) + ')>div>div>div>div>div').click()182 driver.find_element_by_css_selector(183 'div[id="aa_user|aa_user_tab_store"]>div>div>div:nth-child(1)>div:nth-child(2)>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div>div:nth-child(' + str(184 col + 1) + ')>div>div>div>div>div>div>div:nth-child(1)>div>div>span>span>div>i.anticon.anticon-canzhao').click()185 choose_around_store(driver)186def save_operation_button(driver):187 # 点击保存按钮188 driver.find_element_by_id('aa_user|btnSave').click()...

Full Screen

Full Screen

test_fwmgl.py

Source:test_fwmgl.py Github

copy

Full Screen

1from selenium.webdriver.support.select import Select2from public.login import *3# import pyautogui4# 防伪码管理模块测试类5class fwmgl(dl):6 # 批量生成防伪码模块正常新增,默认字段不修改7 def fwmsc_01(self):8 self.wxq.find_element_by_link_text('批量生成防伪码').click()9 time.sleep(2)10 self.wxq.find_element_by_css_selector('div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').send_keys('wee')11 self.wxq.find_element_by_css_selector('div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)').send_keys('100')12 self.wxq.execute_script('document.getElementById("s1").style.display="block";')13 Select(self.wxq.find_element_by_id('s1')).select_by_visible_text('飞来峰')14 time.sleep(3)15 self.wxq.execute_script('document.getElementById("s2").style.display="block";')16 Select(self.wxq.find_element_by_id('s2')).select_by_visible_text('口扩扩')17 time.sleep(3)18 self.wxq.find_element_by_css_selector('#tj').click()19 time.sleep(1)20 a=self.wxq.find_element_by_css_selector('.layui-layer-ico')21 time.sleep(3)22 return a23 # 批量生成防伪码模块修改生成批次为已存在的内容('202011100955477'),其他字段正常输入24 def fwmsc_02(self):25 self.wxq.find_element_by_css_selector('div.form-group:nth-child(1) > div:nth-child(2) > input:nth-child(1)').clear()26 self.wxq.find_element_by_css_selector('div.form-group:nth-child(1) > div:nth-child(2) > input:nth-child(1)').send_keys('202011100955477')27 self.wxq.find_element_by_css_selector(28 'div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').send_keys('wee')29 self.wxq.find_element_by_css_selector(30 'div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)').send_keys('100')31 self.wxq.execute_script('document.getElementById("s1").style.display="block";')32 Select(self.wxq.find_element_by_id('s1')).select_by_visible_text('飞来峰')33 time.sleep(3)34 self.wxq.execute_script('document.getElementById("s2").style.display="block";')35 Select(self.wxq.find_element_by_id('s2')).select_by_visible_text('口扩扩')36 time.sleep(3)37 self.wxq.find_element_by_css_selector('#tj').click()38 time.sleep(1)39 a = self.wxq.find_element_by_css_selector('.layui-layer-ico')40 time.sleep(3)41 return a42 # 批量生成防伪码模块修改防伪码长度不符合建议长度8-18位,反案例43 def fwmsc_03(self):44 self.wxq.find_element_by_css_selector('div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').clear()45 self.wxq.find_element_by_css_selector('div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').send_keys('6')46 time.sleep(3)47 self.wxq.find_element_by_css_selector(48 'div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').send_keys('ABC')49 time.sleep(3)50 self.wxq.find_element_by_css_selector(51 'div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)').send_keys('10')52 self.wxq.execute_script('document.getElementById("s1").style.display="block";')53 Select(self.wxq.find_element_by_id('s1')).select_by_visible_text('飞来峰')54 time.sleep(3)55 self.wxq.execute_script('document.getElementById("s2").style.display="block";')56 Select(self.wxq.find_element_by_id('s2')).select_by_visible_text('口扩扩')57 time.sleep(3)58 self.wxq.find_element_by_css_selector('#tj').click()59 time.sleep(1)60 a = self.wxq.find_element_by_css_selector('.layui-layer-ico')61 time.sleep(3)62 return a63 # 批量生成防伪码模块修改防伪码长度不符合建议前缀前度2-4位,反案例64 def fwmsc_04(self):65 self.wxq.find_element_by_css_selector(66 'div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').clear()67 self.wxq.find_element_by_css_selector(68 'div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').send_keys('10')69 time.sleep(3)70 self.wxq.find_element_by_css_selector(71 'div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').send_keys('asdasdad')72 time.sleep(3)73 self.wxq.find_element_by_css_selector(74 'div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)').send_keys('10')75 self.wxq.execute_script('document.getElementById("s1").style.display="block";')76 Select(self.wxq.find_element_by_id('s1')).select_by_visible_text('飞来峰')77 time.sleep(3)78 self.wxq.execute_script('document.getElementById("s2").style.display="block";')79 Select(self.wxq.find_element_by_id('s2')).select_by_visible_text('枇杷露')80 time.sleep(3)81 self.wxq.find_element_by_css_selector('#tj').click()82 time.sleep(1)83 a = self.wxq.find_element_by_css_selector('.layui-layer-ico')84 time.sleep(3)85 return a86 # 单个生成防伪码模块的正常输入,默认生成字段不修改87 def dgsc_05(self):88 self.wxq.find_element_by_link_text('单个生成防伪码').click()89 time.sleep(1)90 self.wxq.find_element_by_css_selector('div.form-group:nth-child(4) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()91 time.sleep(1)92 self.wxq.find_element_by_css_selector('.has-next > div:nth-child(2) > div:nth-child(5)').click()93 self.wxq.find_element_by_css_selector('div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()94 time.sleep(1)95 self.wxq.find_element_by_css_selector('div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(4)').click()96 self.wxq.find_element_by_css_selector('.btn').click()97 a=self.wxq.find_element_by_css_selector('.layui-layer-content').text98 return a99 #单个生成防伪码模块的正常输入,修改默认字段生成批次的修改100 def dgsc_06(self):101 self.wxq.find_element_by_link_text('单个生成防伪码').click()102 time.sleep(1)103 self.wxq.find_element_by_css_selector('.col-sm-3 > input:nth-child(1)').clear()104 time.sleep(1)105 self.wxq.find_element_by_css_selector('.col-sm-3 > input:nth-child(1)').send_keys('20112036543')106 self.wxq.find_element_by_css_selector(107 'div.form-group:nth-child(4) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()108 time.sleep(1)109 self.wxq.find_element_by_css_selector('.has-next > div:nth-child(2) > div:nth-child(5)').click()110 self.wxq.find_element_by_css_selector(111 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()112 time.sleep(1)113 self.wxq.find_element_by_css_selector(114 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(5)').click()115 self.wxq.find_element_by_css_selector('.btn').click()116 a = self.wxq.find_element_by_css_selector('.layui-layer-content').text117 return a118 #单个生成防伪码模块的正常输入,修改默认字段防伪码的修改119 def dgsc_07(self):120 self.wxq.find_element_by_css_selector('div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').clear()121 time.sleep(1)122 self.wxq.find_element_by_css_selector('div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)').send_keys('asd45ad4aqwe45')123 self.wxq.find_element_by_css_selector(124 'div.form-group:nth-child(4) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()125 time.sleep(1)126 self.wxq.find_element_by_css_selector('.has-next > div:nth-child(2) > div:nth-child(5)').click()127 self.wxq.find_element_by_css_selector(128 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()129 time.sleep(1)130 self.wxq.find_element_by_css_selector(131 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(5)').click()132 self.wxq.find_element_by_css_selector('.btn').click()133 a = self.wxq.find_element_by_css_selector('.layui-layer-content').text134 return a135 # 单个生成防伪码模块的正常输入,修改默认字段物流码的修改136 def dgsc_08(self):137 self.wxq.find_element_by_css_selector(138 'div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').clear()139 time.sleep(1)140 self.wxq.find_element_by_css_selector(141 'div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)').send_keys('786613156123')142 self.wxq.find_element_by_css_selector(143 'div.form-group:nth-child(4) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()144 time.sleep(1)145 self.wxq.find_element_by_css_selector('.has-next > div:nth-child(2) > div:nth-child(5)').click()146 self.wxq.find_element_by_css_selector(147 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()148 time.sleep(1)149 self.wxq.find_element_by_css_selector(150 'div.form-group:nth-child(5) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(5)').click()151 self.wxq.find_element_by_css_selector('.btn').click()152 a = self.wxq.find_element_by_css_selector('.layui-layer-content').text153 return a154 # 批量删除防伪码,按批次删除155 def plsc_09(self):156 self.wxq.find_element_by_link_text('批量删除防伪码').click()157 time.sleep(3)158 self.wxq.find_element_by_css_selector('div.row:nth-child(1) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()159 time.sleep(1)160 self.wxq.find_element_by_css_selector('div.row:nth-child(1) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3)').click()161 self.wxq.find_element_by_xpath('/html/body/section/section/section/div[1]/div/section/div/form/div[2]/div/button').click()162 time.sleep(3)163 # 批量删除防伪码,按产品删除164 def plsc_10(self):165 self.wxq.find_element_by_css_selector(166 'div.row:nth-child(2) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()167 time.sleep(1)168 self.wxq.find_element_by_css_selector(169 '.has-next > div:nth-child(2) > div:nth-child(4)').click()170 self.wxq.find_element_by_xpath(171 '/html/body/section/section/section/div[2]/div/section/div/form/div[2]/div/button').click()172 time.sleep(3)173 # 批量删除防伪码,按生成日期删除174 def plsc_11(self):175 a=self.wxq.find_element_by_css_selector('div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > label:nth-child(1)')176 self.wxq.execute_script('return arguments[0].scrollIntoView();',a)177 self.wxq.find_element_by_css_selector(178 'div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)').click()179 time.sleep(1)180 self.wxq.find_element_by_css_selector(181 'div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2)').click()182 self.wxq.find_element_by_xpath(183 '/html/body/section/section/section/div[3]/div/section/div/form/div[2]/div/button').click()184 time.sleep(3)185 # 批量删除防伪码,按查询次数删除186 def plsc_12(self):187 a = self.wxq.find_element_by_css_selector(188 'div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(1) > label:nth-child(1)')189 self.wxq.execute_script('return arguments[0].scrollIntoView();', a)190 self.wxq.find_element_by_css_selector(191 '.form-control').clear()192 self.wxq.find_element_by_css_selector(193 '.form-control').send_keys('10')194 time.sleep(1)195 self.wxq.find_element_by_xpath(196 '/html/body/section/section/section/div[4]/div/section/div/form/div[2]/div/button').click()197 time.sleep(3)198 # 批量删除防伪码,全部删除199 def plsc_13(self):200 a = self.wxq.find_element_by_css_selector(201 'div.row:nth-child(5) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(2) > label:nth-child(1)')202 self.wxq.execute_script('return arguments[0].scrollIntoView();', a)...

Full Screen

Full Screen

cx_base.py

Source:cx_base.py Github

copy

Full Screen

1import re2def zdyh_cx_weidu(driver,weidu):3 driver.find_element_by_css_selector('div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select').click()4 if weidu=='无':5 driver.find_element_by_css_selector('div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option:nth-child(1)').click()6 elif weidu == '客户':7 driver.find_element_by_css_selector(8 'div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="客户"]').click()9 elif weidu == '客户分类':10 driver.find_element_by_css_selector(11 'div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="客户分类"]').click()12 elif weidu == '客户级别':13 driver.find_element_by_css_selector(14 'div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="客户级别"]').click()15 elif weidu == '区域':16 driver.find_element_by_css_selector(17 'div.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="区域"]').click()18def spcx_weidu(driver,weidu):19 driver.find_element_by_css_selector('form.form-horizontal> div:nth-child(3) > div:nth-child(2) > select').click()20 if weidu=='无':21 driver.find_element_by_css_selector('form.form-horizontal> div:nth-child(3) > div:nth-child(2) > select>option:nth-child(1)').click()22 elif weidu == '客户':23 driver.find_element_by_css_selector(24 'form.form-horizontal> div:nth-child(3) > div:nth-child(2) > select>option[label="客户"]').click()25 elif weidu == '客户分类':26 driver.find_element_by_css_selector(27 'form.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="客户分类"]').click()28 elif weidu == '客户级别':29 driver.find_element_by_css_selector(30 'form.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="客户级别"]').click()31 elif weidu == '区域':32 driver.find_element_by_css_selector(33 'form.form-horizontal > div:nth-child(3) > div:nth-child(2) > select>option[label="区域"]').click()34def zdyh_cx_name(driver,name):35 driver.find_element_by_css_selector('input[ng-model="pName"]').clear()36 driver.find_element_by_css_selector('input[ng-model="pName"]').send_keys(name)37def search_button(driver):38 driver.find_element_by_css_selector('button[ng-click="search()"]').click()39def qy_zdyh_fa(driver,name,tag):40 text=driver.find_element_by_css_selector('div.pagination.m-l-15.ng-binding').text41 str1 = text.split(',')42 str2 = ''.join(str1[:1])43 count=re.sub("\D", "", str2)44 temp_name=''45 for i in range(0,int(count)):46 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))47 for j in range(0,count_tr):48 temp_name=driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2) > span').text49 if temp_name==name:50 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':51 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div > span.switch-right.ng-binding').click()52 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':53 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div > span.switch-right.ng-binding').click()54 break55 if temp_name==name:56 break57 if i>=0 and i<int(count) and int(count)>1:58 driver.find_element_by_css_selector('ul.pagination > li>a[ng-click="pager.selectNext()"]').click()59def qy_spcx_fa(driver,name,tag):60 text=driver.find_element_by_css_selector('div.pagination.m-l-15.ng-binding').text61 str1 = text.split(',')62 str2 = ''.join(str1[:1])63 count=re.sub("\D", "", str2)64 temp_name=''65 for i in range(0,int(count)):66 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))67 for j in range(0,count_tr):68 temp_name=driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2) > span').text69 if temp_name==name:70 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':71 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div > span.switch-right.ng-binding').click()72 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':73 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div > span.switch-right.ng-binding').click()74 break75 if temp_name==name:76 break77 if i>=0 and i<int(count) and int(count)>1:78 driver.find_element_by_css_selector('ul.pagination > li>a[ng-click="pager.selectNext()"]').click()79#整单优惠状态80def zhyh_status(driver,status):81 if status=='全部':82 driver.find_element_by_css_selector('div.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(1)').click()83 elif status=='启用':84 driver.find_element_by_css_selector('div.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(2)').click()85 elif status=='禁用':86 driver.find_element_by_css_selector('div.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(3)').click()87#商品促销状态88def spcx_status(driver,status):89 if status=='全部':90 driver.find_element_by_css_selector('form.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(1)').click()91 elif status=='启用':92 driver.find_element_by_css_selector('form.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(2)').click()93 elif status=='禁用':94 driver.find_element_by_css_selector('form.form-horizontal > div:nth-child(2) > div > div.orderList_form > a:nth-child(3)').click()95#全部启用或者停用96def zdyh_qt_all(driver,tag):97 text=driver.find_element_by_css_selector('div.pagination.m-l-15.ng-binding').text98 str1 = text.split(',')99 str2 = ''.join(str1[:1])100 count=re.sub("\D", "", str2)101 for i in range(0,int(count)):102 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))103 for j in range(0,count_tr):104 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':105 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div > span.switch-right.ng-binding').click()106 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':107 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(7) > div > div > span.switch-right.ng-binding').click()108 if i>=0 and i<int(count) and int(count)>1:109 driver.find_element_by_css_selector('ul.pagination > li>a[ng-click="pager.selectNext()"]').click()110#全部启用或者停用111def spcx_qt_all(driver,tag):112 text=driver.find_element_by_css_selector('div.pagination.m-l-15.ng-binding','findAssert').text113 str1 = text.split(',')114 str2 = ''.join(str1[:1])115 count=re.sub("\D", "", str2)116 for i in range(0,int(count)):117 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))118 for j in range(0,count_tr):119 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':120 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div > span.switch-right.ng-binding').click()121 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':122 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(6) > div > div > span.switch-right.ng-binding').click()123 if i>=0 and i<int(count) and int(count)>1:124 driver.find_element_by_css_selector('ul.pagination > li>a[ng-click="pager.selectNext()"]').click()125#全部启用或者停用126def zhcx_qt_all(driver,tag):127 if driver.find_element_by_css_selector('div.row.space20.ng-scope > div:nth-child(2)').get_attribute('class')=='col-xs-12':128 text=driver.find_element_by_css_selector('div.pagination.pull-right.m-l-5','findAssert').text129 str1 = text.split(',')130 str2 = ''.join(str1[:1])131 count=re.sub("\D", "", str2)132 for i in range(0,int(count)):133 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))134 for j in range(0,count_tr):135 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':136 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div > span.switch-right.ng-binding').click()137 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':138 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div > span.switch-right.ng-binding').click()139 if i>=0 and i<int(count) and int(count)>1:140 driver.find_element_by_css_selector('ul.pagination > li>a[ng-click="pager.selectNext()"]').click()141def qy_zhcx_fa(driver,name,tag):142 text=driver.find_element_by_css_selector('div.pagination.pull-right.m-l-5','findAssert').text143 str1 = text.split(',')144 str2 = ''.join(str1[:1])145 count=re.sub("\D", "", str2)146 temp_name=''147 for i in range(0,int(count)):148 count_tr=len(driver.find_elements_by_css_selector('table > tbody > tr'))149 for j in range(0,count_tr):150 temp_name=driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(2) > span').text151 if temp_name==name:152 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div').get_attribute('class')=='toggle-switch-animate switch-off' and tag=='qy':153 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div > span.switch-right.ng-binding').click()154 if driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div').get_attribute('class')=='toggle-switch-animate switch-on' and tag=='ty':155 driver.find_element_by_css_selector('table > tbody > tr:nth-child('+str(j+1)+') > td:nth-child(5) > div > div > span.switch-right.ng-binding').click()156 break157 if temp_name==name:158 break159 if i>=0 and i<int(count) and int(count)>1:...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful