Best Python code snippet using playwright-python
price_base.py
Source: price_base.py
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:...
yls_rule_operator_base.py
Source: yls_rule_operator_base.py
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()...
test_fwmgl.py
Source: test_fwmgl.py
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)...
cx_base.py
Source: cx_base.py
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:...
Playwright error connection refused in docker
playwright-python advanced setup
How to select an input according to a parent sibling label
Error when installing Microsoft Playwright
Trouble waiting for changes to complete that are triggered by Python Playwright `select_option`
Capturing and Storing Request Data Using Playwright for Python
Can Playwright be used to launch a browser instance
Trouble in Clicking on Log in Google Button of Pop Up Menu Playwright Python
Scrapy Playwright get date by clicking button
React locator example
I solved my problem. In fact my docker container (frontend) is called "app" which is also domain name of fronend application. My application is running locally on http. Chromium and geko drivers force httpS connection for some domain names one of which is "app". So i have to change name for my docker container wich contains frontend application.
Check out the latest blogs from LambdaTest on this topic:
The sky’s the limit (and even beyond that) when you want to run test automation. Technology has developed so much that you can reduce time and stay more productive than you used to 10 years ago. You needn’t put up with the limitations brought to you by Selenium if that’s your go-to automation testing tool. Instead, you can pick from various test automation frameworks and tools to write effective test cases and run them successfully.
When it comes to web automation testing, there are a number of frameworks like Selenium, Cypress, PlayWright, Puppeteer, etc., that make it to the ‘preferred list’ of frameworks. The choice of test automation framework depends on a range of parameters like type, complexity, scale, along with the framework expertise available within the team. However, it’s no surprise that Selenium is still the most preferred framework among developers and QAs.
Playwright is a framework that I’ve always heard great things about but never had a chance to pick up until earlier this year. And since then, it’s become one of my favorite test automation frameworks to use when building a new automation project. It’s easy to set up, feature-packed, and one of the fastest, most reliable frameworks I’ve worked with.
The speed at which tests are executed and the “dearth of smartness” in testing are the two major problems developers and testers encounter.
With the rapidly evolving technology due to its ever-increasing demand in today’s world, Digital Security has become a major concern for the Software Industry. There are various ways through which Digital Security can be achieved, Captcha being one of them.Captcha is easy for humans to solve but hard for “bots” and other malicious software to figure out. However, Captcha has always been tricky for the testers to automate, as many of them don’t know how to handle captcha in Selenium or using any other test automation framework.
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.
Get 100 minutes of automation test minutes FREE!!