Best Python code snippet using robotframework-appiumlibrary_python
SaturnVaultTests.py
Source:SaturnVaultTests.py
...54 del_buttons = driver.find_elements_by_class_name("btn-danger")55 if del_buttons:56 del_buttons[0].click()57 time.sleep(1)58 click_text("Delete")59def check_pass_exists(s):60 tds = driver.find_elements_by_css_selector("table > tbody > tr > td")61 if tds:62 site_name = tds[2].text63 if site_name == s:64 return True65 else:66 return False67def goto_url(dest):68 driver.get(url+dest)69def click_class(c):70 driver.find_element_by_class(c).click()71def click_id(i):72 driver.find_element_by_id(i).click()73def click_text(text):74 driver.find_element_by_xpath("//*[contains(text(), \'"+text+"\')]").click()75 76class TestHeader(unittest.TestCase):77 78 def test_C1(self):79 s = "siteC1"80 u = "cats@cats.com"81 p = "stickman123"82 goto_url("/#/saturn-vault/new")83 time.sleep(1)84 input_credentials(s, u, p)85 time.sleep(1)86 driver.find_element_by_css_selector("form[name='editForm']").submit()87 time.sleep(1)88 result = check_pass_exists(s)89 cleanup()90 self.assertEqual(result, True)91 def test_C2(self):92 s = "siteC2"93 u = "seng426"94 p = "lildaddy"95 goto_url("/#/saturn-vault/new")96 time.sleep(1)97 input_credentials(s, u, p)98 time.sleep(1)99 click_text("Cancel")100 result = check_pass_exists(s)101 if not result:102 cleanup()103 self.assertEqual(result, False)104 def test_C3(self):105 s = "siteC3"106 u = "cats@cats.com"107 p = None108 l = 20109 result = True110 goto_url("/#/saturn-vault/new")111 time.sleep(1)112 input_credentials(s, u, p)113 time.sleep(1)114 click_text("Generate")115 time.sleep(1)116 tick_boxes(1, 0, 0, 0, 0)117 time.sleep(1)118 set_len(str(l))119 click_id("generate_password")120 time.sleep(1)121 password = driver.find_element_by_id("field_password").get_attribute('value')122 time.sleep(1)123 if not re.match(r"[a-z]+", password):124 result = False125 if len(password) != l:126 result = False127 click_text("Use")128 time.sleep(1)129 driver.find_element_by_css_selector("form[name='editForm']").submit()130 time.sleep(1)131 if result:132 result = check_pass_exists(s)133 cleanup()134 self.assertEqual(result, True)135 def test_C4(self):136 s = "siteC4"137 u = "cats@cats.com"138 p = None139 l = 20140 result = True141 goto_url("/#/saturn-vault/new")142 time.sleep(1)143 input_credentials(s, u, p)144 time.sleep(1)145 click_text("Generate")146 time.sleep(1)147 tick_boxes(1, 1, 0, 0, 0)148 time.sleep(1)149 set_len(str(l))150 click_id("generate_password")151 time.sleep(1)152 password = driver.find_element_by_id("field_password").get_attribute('value')153 time.sleep(1)154 if not re.match(r"[a-zA-Z]+", password):155 result = False156 if len(password) != l:157 result = False158 click_text("Use")159 time.sleep(1)160 driver.find_element_by_css_selector("form[name='editForm']").submit()161 time.sleep(1)162 if result:163 result = check_pass_exists(s)164 cleanup()165 self.assertEqual(result, True)166 167 def test_C5(self):168 s = "siteC5"169 u = "cats@cats.com"170 p = None171 l = 20172 result = True173 goto_url("/#/saturn-vault/new")174 time.sleep(1)175 input_credentials(s, u, p)176 time.sleep(1)177 click_text("Generate")178 time.sleep(1)179 tick_boxes(1, 1, 1, 0, 0)180 time.sleep(1)181 set_len(str(l))182 click_id("generate_password")183 time.sleep(1)184 password = driver.find_element_by_id("field_password").get_attribute('value')185 time.sleep(1)186 if not re.match(r"[a-zA-Z0-9]+", password):187 result = False188 if len(password) != l:189 result = False190 click_text("Use")191 time.sleep(1)192 driver.find_element_by_css_selector("form[name='editForm']").submit()193 time.sleep(1)194 if result:195 result = check_pass_exists(s)196 cleanup()197 self.assertEqual(result, True)198 199 def test_C6(self):200 s = "siteC6"201 u = "cats@cats.com"202 p = None203 l = 20204 result = True205 goto_url("/#/saturn-vault/new")206 time.sleep(1)207 input_credentials(s, u, p)208 time.sleep(1)209 click_text("Generate")210 time.sleep(1)211 tick_boxes(1, 1, 1, 1, 0)212 time.sleep(1)213 set_len(str(l))214 click_id("generate_password")215 time.sleep(1)216 password = driver.find_element_by_id("field_password").get_attribute('value')217 time.sleep(1)218 if not re.match(r"[a-zA-Z0-9!@#$%_-]+", password):219 result = False220 if len(password) != l:221 result = False222 click_text("Use")223 time.sleep(1)224 driver.find_element_by_css_selector("form[name='editForm']").submit()225 time.sleep(1)226 if result:227 result = check_pass_exists(s)228 cleanup()229 self.assertEqual(result, True)230 def test_C7(self):231 s = "siteC7"232 u = "cats@cats.com"233 p = None234 l = 20235 result = True236 goto_url("/#/saturn-vault/new")237 time.sleep(1)238 input_credentials(s, u, p)239 time.sleep(1)240 click_text("Generate")241 time.sleep(1)242 tick_boxes(1, 1, 1, 1, 1)243 time.sleep(1)244 set_len(str(l))245 click_id("generate_password")246 time.sleep(1)247 password = driver.find_element_by_id("field_password").get_attribute('value')248 time.sleep(1)249 if not re.match(r"[a-zA-Z0-9!@#$%_-]+", password):250 result = False251 if len(password) != l:252 result = False253 if not unique(password):254 result = False255 click_text("Use")256 time.sleep(1)257 driver.find_element_by_css_selector("form[name='editForm']").submit()258 time.sleep(1)259 if result:260 result = check_pass_exists(s)261 cleanup()262 self.assertEqual(result, True)263 264 def test_C8(self):265 s = "siteC8"266 u = "cats@cats.com"267 p = None268 l = 20269 result = True270 goto_url("/#/saturn-vault/new")271 time.sleep(1)272 input_credentials(s, u, p)273 time.sleep(1)274 click_text("Generate")275 time.sleep(1)276 tick_boxes(1, 1, 1, 1, 1)277 time.sleep(1)278 set_len(str(l))279 click_id("generate_password")280 time.sleep(1)281 click_id("cancel_pass_gen")282 time.sleep(1)283 click_text("Cancel")284 time.sleep(1)285 if result:286 result = check_pass_exists(s)287 self.assertEqual(result, False)288 def test_E1(self):289 s = "siteE1"290 u = "cats@cats.com"291 p = "stickman123"292 s_edit = "siteE1Edit"293 u_edit = "dogs@dogs.com"294 p_edit = "rat123"295 goto_url("/#/saturn-vault/new")296 time.sleep(1)297 input_credentials(s, u, p)298 time.sleep(1)299 driver.find_element_by_css_selector("form[name='editForm']").submit()300 time.sleep(1)301 edit_buttons = driver.find_elements_by_class_name("btn-info")302 edit_buttons[0].click()303 time.sleep(1)304 input_credentials(s_edit, u_edit, p_edit)305 time.sleep(1)306 driver.find_element_by_css_selector("form[name='editForm']").submit()307 time.sleep(1)308 result = check_pass_exists(s_edit)309 time.sleep(1)310 cleanup()311 time.sleep(1)312 self.assertEqual(result, True)313 def test_E2(self):314 s = "siteE2"315 u = "cats@cats.com"316 p = "stickman123"317 s_edit = "siteE2Edit"318 u_edit = "dogs@dogs.com"319 p_edit = "rat123"320 goto_url("/#/saturn-vault/new")321 time.sleep(1)322 input_credentials(s, u, p)323 time.sleep(1)324 driver.find_element_by_css_selector("form[name='editForm']").submit()325 time.sleep(1)326 edit_buttons = driver.find_elements_by_class_name("btn-info")327 edit_buttons[0].click()328 time.sleep(1)329 input_credentials(s_edit, u_edit, p_edit)330 time.sleep(1)331 click_text("Cancel")332 time.sleep(1)333 result = check_pass_exists(s)334 time.sleep(1)335 cleanup()336 time.sleep(1)337 self.assertEqual(result, True)338 def test_E3(self):339 s = "siteE3"340 u = "cats@cats.com"341 p = "stickman123"342 l = 20343 result = True344 goto_url("/#/saturn-vault/new")345 time.sleep(1)346 input_credentials(s, u, p)347 time.sleep(1)348 driver.find_element_by_css_selector("form[name='editForm']").submit()349 time.sleep(1)350 edit_buttons = driver.find_elements_by_class_name("btn-info")351 edit_buttons[0].click()352 time.sleep(1)353 click_text("Generate")354 time.sleep(1)355 tick_boxes(1, 0, 0, 0, 0)356 time.sleep(1)357 set_len(str(l))358 click_id("generate_password")359 time.sleep(1)360 password = driver.find_element_by_id("field_password").get_attribute('value')361 time.sleep(1)362 if not re.match(r"[a-z]+", password):363 result = False364 if len(password) != l:365 result = False366 click_text("Use")367 time.sleep(1)368 password_2 = driver.find_element_by_id("field_password").get_attribute('value')369 if password_2 != password:370 result = False371 driver.find_element_by_css_selector("form[name='editForm']").submit()372 time.sleep(1)373 if result:374 result = check_pass_exists(s)375 cleanup()376 time.sleep(1)377 self.assertEqual(result, True)378 def test_E4(self):379 s = "siteE4"380 u = "cats@cats.com"381 p = "stickman123"382 l = 20383 result = True384 goto_url("/#/saturn-vault/new")385 time.sleep(1)386 input_credentials(s, u, p)387 time.sleep(1)388 driver.find_element_by_css_selector("form[name='editForm']").submit()389 time.sleep(1)390 edit_buttons = driver.find_elements_by_class_name("btn-info")391 edit_buttons[0].click()392 time.sleep(1)393 click_text("Generate")394 time.sleep(1)395 tick_boxes(1, 1, 0, 0, 0)396 time.sleep(1)397 set_len(str(l))398 click_id("generate_password")399 time.sleep(1)400 password = driver.find_element_by_id("field_password").get_attribute('value')401 time.sleep(1)402 if not re.match(r"[a-zA-Z]+", password):403 result = False404 if len(password) != l:405 result = False406 click_text("Use")407 time.sleep(1)408 password_2 = driver.find_element_by_id("field_password").get_attribute('value')409 if password_2 != password:410 result = False411 driver.find_element_by_css_selector("form[name='editForm']").submit()412 time.sleep(1)413 if result:414 result = check_pass_exists(s)415 cleanup()416 time.sleep(1)417 self.assertEqual(result, True)418 def test_E5(self):419 s = "siteE5"420 u = "cats@cats.com"421 p = "stickman123"422 l = 20423 result = True424 goto_url("/#/saturn-vault/new")425 time.sleep(1)426 input_credentials(s, u, p)427 time.sleep(1)428 driver.find_element_by_css_selector("form[name='editForm']").submit()429 time.sleep(1)430 edit_buttons = driver.find_elements_by_class_name("btn-info")431 edit_buttons[0].click()432 time.sleep(1)433 click_text("Generate")434 time.sleep(1)435 tick_boxes(1, 1, 1, 0, 0)436 time.sleep(1)437 set_len(str(l))438 click_id("generate_password")439 time.sleep(1)440 password = driver.find_element_by_id("field_password").get_attribute('value')441 time.sleep(1)442 if not re.match(r"[a-zA-Z0-9]+", password):443 result = False444 if len(password) != l:445 result = False446 click_text("Use")447 time.sleep(1)448 password_2 = driver.find_element_by_id("field_password").get_attribute('value')449 if password_2 != password:450 result = False451 driver.find_element_by_css_selector("form[name='editForm']").submit()452 time.sleep(1)453 if result:454 result = check_pass_exists(s)455 cleanup()456 time.sleep(1)457 self.assertEqual(result, True)458 def test_E6(self):459 s = "siteE6"460 u = "cats@cats.com"461 p = "stickman123"462 l = 20463 result = True464 goto_url("/#/saturn-vault/new")465 time.sleep(1)466 input_credentials(s, u, p)467 time.sleep(1)468 driver.find_element_by_css_selector("form[name='editForm']").submit()469 time.sleep(1)470 edit_buttons = driver.find_elements_by_class_name("btn-info")471 edit_buttons[0].click()472 time.sleep(1)473 click_text("Generate")474 time.sleep(1)475 tick_boxes(1, 1, 1, 1, 0)476 time.sleep(1)477 set_len(str(l))478 click_id("generate_password")479 time.sleep(1)480 password = driver.find_element_by_id("field_password").get_attribute('value')481 time.sleep(1)482 if not re.match(r"[a-zA-Z0-9!@#$%_-]+", password):483 result = False484 if len(password) != l:485 result = False486 click_text("Use")487 time.sleep(1)488 password_2 = driver.find_element_by_id("field_password").get_attribute('value')489 if password_2 != password:490 result = False491 driver.find_element_by_css_selector("form[name='editForm']").submit()492 time.sleep(1)493 if result:494 result = check_pass_exists(s)495 cleanup()496 time.sleep(1)497 self.assertEqual(result, True)498 def test_E7(self):499 s = "siteE7"500 u = "cats@cats.com"501 p = "stickman123"502 l = 20503 result = True504 goto_url("/#/saturn-vault/new")505 time.sleep(1)506 input_credentials(s, u, p)507 time.sleep(1)508 driver.find_element_by_css_selector("form[name='editForm']").submit()509 time.sleep(1)510 edit_buttons = driver.find_elements_by_class_name("btn-info")511 edit_buttons[0].click()512 time.sleep(1)513 click_text("Generate")514 time.sleep(1)515 tick_boxes(1, 1, 1, 1, 1)516 time.sleep(1)517 set_len(str(l))518 click_id("generate_password")519 time.sleep(1)520 password = driver.find_element_by_id("field_password").get_attribute('value')521 time.sleep(1)522 if not re.match(r"[a-zA-Z0-9!@#$%_-]+", password):523 result = False524 if len(password) != l:525 result = False526 if not unique(password):527 result = False528 click_text("Use")529 time.sleep(1)530 password_2 = driver.find_element_by_id("field_password").get_attribute('value')531 if password_2 != password:532 result = False533 driver.find_element_by_css_selector("form[name='editForm']").submit()534 time.sleep(1)535 if result:536 result = check_pass_exists(s)537 cleanup()538 time.sleep(1)539 self.assertEqual(result, True)540 def test_E8(self):541 s = "siteE8"542 u = "cats@cats.com"543 p = "stickman123"544 l = 20545 result = True546 goto_url("/#/saturn-vault/new")547 time.sleep(1)548 input_credentials(s, u, p)549 time.sleep(1)550 driver.find_element_by_css_selector("form[name='editForm']").submit()551 time.sleep(1)552 edit_buttons = driver.find_elements_by_class_name("btn-info")553 edit_buttons[0].click()554 time.sleep(1)555 click_text("Generate")556 time.sleep(1)557 tick_boxes(1, 0, 0, 0, 0)558 time.sleep(1)559 set_len(str(l))560 click_id("generate_password")561 time.sleep(1)562 password = driver.find_element_by_id("field_password").get_attribute('value')563 time.sleep(1)564 click_id("cancel_pass_gen")565 time.sleep(1)566 password_2 = driver.find_element_by_id("field_password").get_attribute('value')567 if password_2 != p:568 result = False569 driver.find_element_by_css_selector("form[name='editForm']").submit()570 time.sleep(1)571 if result:572 result = check_pass_exists(s)573 cleanup()574 time.sleep(1)575 self.assertEqual(result, True)576 def test_D1(self):577 s = "siteD1"578 u = "cats@cats.com"579 p = "stickman123"580 goto_url("/#/saturn-vault/new")581 time.sleep(1)582 input_credentials(s, u, p)583 time.sleep(1)584 driver.find_element_by_css_selector("form[name='editForm']").submit()585 time.sleep(1)586 del_buttons = driver.find_elements_by_class_name("btn-danger")587 del_buttons[0].click()588 time.sleep(1)589 click_text("Delete")590 time.sleep(1)591 del_buttons = driver.find_elements_by_class_name("btn-danger")592 time.sleep(1)593 result = check_pass_exists(s)594 time.sleep(1)595 self.assertEqual(result, False)596 def test_D2(self):597 s = "siteD2"598 u = "cats@cats.com"599 p = "stickman123"600 goto_url("/#/saturn-vault/new")601 time.sleep(1)602 input_credentials(s, u, p)603 time.sleep(1)604 driver.find_element_by_css_selector("form[name='editForm']").submit()605 time.sleep(1)606 del_buttons = driver.find_elements_by_class_name("btn-danger")607 del_buttons[0].click()608 time.sleep(1)609 click_text("Cancel")610 result = check_pass_exists(s)611 time.sleep(1)612 cleanup()613 self.assertEqual(result, True)614 615if __name__ == '__main__':616 login(account_u, account_p)617 unittest.main()...
ledgerPage.py
Source:ledgerPage.py
1import time2from .basePage import BasePage3from selenium.webdriver.common.by import By4class LedgerPage(BasePage):5 """6 è´¦æ¬é¡µé¢7 """8 add_ledger_btn = (By.CLASS_NAME, 'anticon-plus')9 ledger_name_input = (By.ID, 'normal_login_ledgerName')10 ledger_node_btn = (By.CLASS_NAME, 'ant-space-align-center')11 submit_btn = (By.CLASS_NAME, 'submit_btn')12 add_sub_node_btn = (By.XPATH,13 '//*[@id="root"]/div/section/section/div/div/main/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr[1]/td[5]/div/div[1]/span/span')14 close_ledger_btn = (By.XPATH, '/html/body/div[4]/div/div/div/div[2]/div/div[2]/button[2]/span')15 choice_add_node_btn = (By.XPATH, '//*[text()="æ·»å "]')16 ledgerManger = (By.XPATH, '//*[text()="è´¦æ¬ç®¡ç"]')17 new_ledger_node_btn = (By.XPATH, '//*[text()="æ°å¢èç¹"]')18 delete_btn = (By.XPATH, '//*[text()="å é¤"]')19 to_public_btn = (By.XPATH, '//*[text()="ä¿®æ¹ä¸ºå
±è¯èç¹"]')20 to_normal_btn = (By.XPATH, '//*[text()="ä¿®æ¹ä¸ºè§å¯è
èç¹"]')21 auth_btn = (By.XPATH, '//*[@id="root"]/div/section/section/div/div/main/div/div/div[1]/div[2]/div/div[2]/button')22 re_auth_btn = (By.XPATH, '//*[@id="root"]/div/section/section/div/div/main/div/div/div[1]/div[2]/div/div[3]/button')23 close_btn = (By.CLASS_NAME, 'ant-modal-close-x')24 def add_ledger(self, name, index=0):25 """26 æ·»å è´¦æ¬27 index: æå®åªä¸ä¸ª28 """29 self.select_ledger_index()30 self.click_Text('æ°å»ºè´¦æ¬', mark='ç¹å»æ·»å è´¦æ¬')31 self.input_Text(self.ledger_name_input, name, mark='è¾å
¥è´¦æ¬åå')32 node_list = self.find_Elements(self.choice_add_node_btn)33 time.sleep(1)34 node_list[index].click()35 self.click_Text('æ 交')36 def add_sub_node(self):37 """38 è´¦æ¬ä¸æ·»å åèç¹39 """40 self.select_ledger_index()41 self.click_Element(self.add_sub_node, mark='æ·»å åèç¹')42 def close_ledger(self, index=1):43 """44 å
³éè´¦æ¬45 """46 self.select_ledger_index()47 ledger_close_btn = (By.XPATH,48 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr[{index}]/td[5]/div/div[2]/span/span')49 self.click_Element(ledger_close_btn, mark='å
³éè´¦æ¬')50 time.sleep(1)51 self.click_Text('ç¡® 认')52 def select_ledger_index(self):53 self.click_Element(self.ledgerManger, mark='éæ©è´¦æ¬ç®¡ç页å¡')54 time.sleep(1)55 def add_specify_node(self, name, start=None, end=None, auto=True):56 """57 æ·»å è´¦æ¬,æ·»å ç¹å®èå´çèç¹58 usage:[1,3]ï¼æ·»å 第2个ã第3个èç¹59 auto: Falseä¸æ·»å ä»»ä½èç¹60 """61 self.select_ledger_index()62 self.click_Text('æ°å»ºè´¦æ¬', mark='ç¹å»æ·»å è´¦æ¬')63 self.input_Text(self.ledger_name_input, name, mark='è¾å
¥è´¦æ¬åå')64 if auto:65 node_list = self.find_Elements(self.choice_add_node_btn)66 for i in node_list[start:end]:67 time.sleep(1)68 # from selenium.webdriver.remote.webelement import WebElement69 # if isinstance(WebElement, i): # å¤ææ¯å¦æ¯å¯ç¨å
ç´ 70 i.click()71 else:72 pass73 self.click_Text('æ 交')74 def enter_ledger_detail(self, index=1):75 """76 è¿å
¥è´¦æ¬è¯¦æ
页77 """78 self.select_ledger_index()79 time.sleep(3) # åå§åè¦æ¶é´80 x = (By.XPATH,81 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr[{index}]/td[2]/a')82 self.click_Element(x, mark=f'ç¹å»ç¬¬{index}个账æ¬åï¼è¿å
¥è¯¦æ
页')83 def add_ledger_node(self, num=1):84 """85 è¿å
¥è´¦æ¬è¯¦æ
页--æ·»å èç¹86 :num ï¼æ·»å èç¹ç个æ°ï¼è³å°187 """88 self.click_Text("æ°å¢èç¹", mark='è´¦æ¬æ·»å åèç¹')89 node_list = self.find_Elements(self.choice_add_node_btn)90 try:91 for i in range(num):92 node_list[i].click()93 except IndexError as e:94 print('个æ°è¶çï¼', e)95 def modify_2pulicnode(self, num=1):96 """97 è´¦æ¬ä¸ï¼ä¿®æ¹è§å¯è
èç¹ä¸ºå
±è¯èç¹98 """99 node_list = self.find_Elements(self.to_public_btn, mark='æ¾æå¤å°ä¸ªä¿®æ¹å
±è¯èç¹æ°')100 try:101 for i in range(num):102 node_list[i].click()103 self.click_Text('ç¡® 认')104 except IndexError as e:105 print('个æ°è¶çï¼', e)106 def modify_2noramlnode(self, num=1):107 """108 è´¦æ¬ä¸ï¼ä¿®æ¹å
±è¯èç¹ä¸ºè§å¯è
èç¹109 """110 node_list = self.find_Elements(self.to_normal_btn, mark='æ¾æå¤å°ä¸ªä¿®æ¹è§å¯è
èç¹æ°')111 try:112 for i in range(num):113 node_list[i].click()114 x = (By.XPATH, '//*[text()="å
±è¯èç¹æ°éä¸è½å°äºèç¹å表æ°éç2/3"]')115 if self.wait_eleVisible(x, timeout=5):116 print('====>å
±è¯èç¹æ°éä¸è½å°äºèç¹å表æ°éç2/3<====')117 raise118 else:119 self.click_Text('ç¡® 认')120 except IndexError as e:121 print('个æ°è¶çï¼', e)122 def delete_node(self, num):123 """124 å é¤è´¦æ¬ä¸çè§å¯è
èç¹125 """126 node_list = self.find_Elements(self.delete_btn, mark='æ¾æå¤å°ä¸ªå¯å é¤èç¹æ°')127 try:128 for i in range(num):129 node_list[i].click()130 self.click_Text('ç¡® 认')131 except IndexError as e:132 print('个æ°è¶çï¼', e)133 def authorize(self, index=1):134 """135 ææ136 """137 self.click_Element(self.auth_btn, mark='ææ')138 time.sleep(1)139 if index == 1:140 x = (By.XPATH,141 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[4]/div/div[2]/div/div[2]/div[2]/div[1]/div/div/div/div/div/div/table/tbody/tr/td[3]/div/div/span/span')142 else:143 x = (By.XPATH,144 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[4]/div/div[2]/div/div[2]/div[2]/div[1]/div/div/div/div/div/div/table/tbody/tr[{index}]/td[3]/div/div/span/span')145 self.click_Element(x)146 def re_authorize(self, index=1):147 """148 åæ¶æé149 """150 self.click_Element(self.re_auth_btn, mark='åæ¶æé')151 time.sleep(1)152 if index == 1:153 x = (By.XPATH,154 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[4]/div/div[2]/div/div[2]/div[2]/div[1]/div/div/div/div/div/div/table/tbody/tr/td[3]/div/div/span/span')155 else:156 x = (By.XPATH,157 f'//*[@id="root"]/div/section/section/div/div/main/div/div/div[4]/div/div[2]/div/div[2]/div[2]/div[1]/div/div/div/div/div/div/table/tbody/tr[{index}]/td[3]/div/div/span/span')158 self.click_Element(x)159 def close_ledger_window(self):160 # å
³éæ°å»ºè´¦æ¬çªå£æé®161 try:162 self.click_Element(self.close_btn)163 except:...
CITIC.py
Source:CITIC.py
...22 time.sleep(5)23 #start app24 self.adb_obj.startapp(self.result['deviceid'],self.package)25 time.sleep(20)26 self.click_text("æç",ck,None,0,0)27 self.click_text("转账",ck,1,0,0)28 time.sleep(10)29 self.click_text("请è¾å
¥å¯ç ",ck,1,0,0)30 time.sleep(10)31 self.tappassword()32 time.sleep(10)33 self.click_text("ç»å½",ck,1,0,0)34 def transfer(self,ft):35 device_list = self.adb_obj.getdevicelist()36 if self.result['deviceid'] not in device_list:37 return "101"38 w = self.adb_obj.getW(self.result['deviceid'])39 h = self.adb_obj.getH(self.result['deviceid'])40 ck = Citickeyboard(w,h)41 if ck.device_support is False:42 self.errmsg = "Not support mobile!"43 return "102"44 self.keyboard_pos = ck.set_c_pos()45 self.keyboard_npos = ck.set_n_pos()46 waked = self.adb_obj.isAwaked(self.result['deviceid'])47 print(waked)48 if ft is True:49 self.login(ck)50 print("login repeat ft is true")51 else:52 print("继ç»è½¬è´¦ no login")53 tc = self.click_text("继ç»è½¬è´¦",ck,1,0,0)54 if tc is False:55 print("tc is false!")56 self.login(ck)57 time.sleep(10)58 self.click_text("é¶è¡å¡è½¬è´¦",ck,1,0,0)59 time.sleep(10)60 self.click_text("æ¶æ¬¾äºº",ck,1,200,0)61 time.sleep(1)62 self.adb_obj.change_adbkeyboard(self.result['deviceid'])63 time.sleep(2)64 # input name65 self.adb_obj.input_ch(self.result['hm'],self.result['deviceid'])66 time.sleep(0.5)67 # hidden others68 self.click_text("ä¸ä¸æ¥",ck,1,0,0)69 # input cardnumber70 self.click_text("æ¶æ¬¾è´¦å·",ck,1,200,0)71 for s in self.result['cardnumber']:72 cmd = "adb -s "+self.result['deviceid']+" shell input text "+s73 os.system(cmd)74 # input money75 self.click_text("转账éé¢",ck,1,200,100)76 cmd = "adb -s "+self.result['deviceid']+" shell input text "+self.result['money']77 os.system(cmd)78 # hidden others79 self.click_text("ä¸ä¸æ¥",ck,1,0,-50)80 time.sleep(1)81 self.adb_obj.restartsms(self.result['deviceid'],self.package)82 self.click_text("ä¸ä¸æ¥",ck,1,0,0)83 # input sms84 85 self.click_text("è·åéªè¯ç ",ck,1,-200,0)86 sms = self.my_tool.getsms(self.result['mobile'])87 if sms =="123456" or sms is None:88 self.errmsg = "sms error!"89 return "102"90 for c in sms:91 print(c)92 for p in self.keyboard_npos:93 if c == p:94 self.adb_obj.tap_pos(self.result['deviceid'],self.keyboard_npos[p][0],self.keyboard_npos[p][1])95 break96 97 self.click_text("ç¡®å®",ck,1,0,0)98 time.sleep(7)99 p = self.adb_obj.touch_xml(self.result['deviceid'])100 t = self.find_element_byText("转账æå")101 if t:102 try:103 print("转账æå")104 self.my_tool.set_first_transferFlag(self.result['deviceid'],"no")105 except:106 print("------------------------------------------------------error")107 return "10000"108 else:109 try:110 print("转账weizhi")111 self.my_tool.set_first_transferFlag(self.result['deviceid'],"yes")112 except:113 print("------------------------------------------------------error2")114 return "20000"115 def click_text(self,text,ck,bounds,m_x,m_y):116 p = self.adb_obj.touch_xml(self.result['deviceid'])117 if p:118 ad = self.click_resource("com.ecitic.bank.mobile:id/close_product_send",0,0)119 if ad:120 p = self.adb_obj.touch_xml(self.result['deviceid'])121 t = self.find_element_byText(text)122 if t:123 if bounds is None:124 self.adb_obj.tap_pos(self.result['deviceid'],ck.my_x,ck.my_y)125 else:126 self.adb_obj.tap_pos(self.result['deviceid'],self.click_pos_x+m_x,self.click_pos_y+m_y)127 print("clicked!")128 return True129 else:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!