Best Python code snippet using pom_python
personality_sri.py
Source:personality_sri.py
...10dvr=webdriver.Chrome('./chromedriver')11url='https://www.saramin.co.kr/zf_user/auth?url=%2Fzf_user%2F'12dvr.get(url)13#ë¡ê·¸ì¸14com_btn=dvr.find_element(By.XPATH,'//*[@id="login_frm"]/div[2]/div[1]/ul[1]/li[2]/a')15id_box=dvr.find_element(By.CSS_SELECTOR,'#id')16pw_box=dvr.find_element(By.CSS_SELECTOR,'#password')17lgn_btn=dvr.find_element(By.CSS_SELECTOR,'#login_frm > div.login_page_wrap > div.login_input_wrap > div.login-form > button')18com_btn.click()19id_box.send_keys(id)20pw_box.send_keys(pw)21lgn_btn.click()22#ì¸ì ì± í ì´ë23dvr.get('https://www.saramin.co.kr/zf_user/memcom/preview/home')24#ê²ì¬ ë±ë¡ ë²í¼ í´ë¦25dvr.find_element(By.CSS_SELECTOR,'#preview_home_area > div.wrap_top_human > div.area_right > div.area_card.newly_card > div > button').click()26# ì¸ì ì± ì¢
ë¥ ì í27dvr.find_element(By.CSS_SELECTOR,'#exam_category').click()28# ì¬ëì¸hr ì°êµ¬ì ì¸ì ì±ê²ì¬ ì í29dvr.find_element(By.XPATH, '//*[@id="exam_category"]/option[10]').click()30# ì¸ì ì±ê²ì¬ëª
31rec_nm=dvr.find_element(By.CSS_SELECTOR, '#exam_title')32# ì+ì¼ 4ìë¡ ë³´ì¬ì£¼ê¸° (ex. 0628)33# a=문ìí(ì¤ë.ì).2ì리 ë ëê¹ì§ 0ì¼ë¡ ì±ì°ê¸°+문ìí(ì¤ë, ì¼).2ì리 ë ëê¹ì§ 0ì¼ë¡ ì±ì°ê¸°34a=(str(datetime.today().month).zfill(2)+str(datetime.today().day).zfill(2))35#ì 목: a+ì 목+i36rec_nm.send_keys(a+' ì¬ëì¸ ì¸ì ì± í
ì¤í¸ ')37#ìë´ ë°©ë²38dvr.find_element(By.CSS_SELECTOR, '#auto_alarm_ck_not_send').send_keys(Keys.SPACE)39# ìììë£ ì림 ì¤ì 40dvr.find_element(By.CSS_SELECTOR, '#complete_noti_type_none').send_keys(Keys.SPACE)41# ë±ë¡ ë²í¼ í´ë¦42dvr.find_element(By.CSS_SELECTOR, '#add_exam_button').click()43dvr.switch_to.alert.accept()44#ìí 미보ì ì²´í¬:ì¼ë¨ ëª¨ë¬ ë ì´ì´ ì 목ì ê°ì ¸ìë³´ê³ , ì¤í¨íë©´ 0ì¼ë¡ ë£ê¸°45try: product = dvr.find_element(By.CSS_SELECTOR, '#preview_no_have_product_layer > div.modalTit > h3')46except:product=047try: add = dvr.find_element(By.CSS_SELECTOR, '#add_preview_user_layer > div.modalTit > h3')48except:add=049# ë³ìì ë¤ì´ìëê² 0ì´ ìëë©´ (ì ëª©ì´ ê°ì ¸ìì§ë©´) ê·¸ì ë§ë íëì íê²ë50if (add!=0):51 # ìíì´ ìì ê²½ì°ìë§ êµ¬ë§¤ë¥¼ íë íë¡ì¸ì¤ê° ì¶ê°ëê³ , ìììì¶ê°ë ëì¼íê² í기 ë문ì ììì ì¶ê°ë if문 ë°ì ì§ê³ ì¬ê¸°ì í¨ì¤52 pass53elif (product!=0):54 #모ë¬ìì 구매 ë²í¼ ë르기55 dvr.find_element(By.CSS_SELECTOR, '#preview_no_have_product_layer > div.modalBtn.box_verify_btn > button').click()56 #ê²°ì ì°½ì´ ìì°½ì¼ë¡ ì´ë¦¬ëê¹ ê·¸ ì°½ì¼ë¡ í¬ì»¤ì¤ ë°ê¾¸ê¸°57 dvr.switch_to.window(dvr.window_handles[1])58 #í¬ì¸í¸ ì ì¡ì¬ì© ë²í¼ ë르기59 dvr.find_element(By.CSS_SELECTOR, '#content > div.product_order > div > div.apply_discount > dl:nth-child(5) > dd:nth-child(2) > button').click()60 61 # ê²°ì ëì ì²´í¬ë°ì¤ ë르기62 dvr.find_element(By.CSS_SELECTOR, '#isPaymentAgreement').send_keys(Keys.SPACE)63 # ê²°ì í기 ë르기64 dvr.find_element(By.CSS_SELECTOR, '#makePayment').click()65 time.sleep(5)66 # ì¸ì ì± ê´ë¦¬ íì´ì§ ì´ê¸°67 dvr.get('https://www.saramin.co.kr/zf_user/memcom/preview/main')68 # ììì ì¶ê° ë²í¼ ë르기69 dvr.find_element(By.CSS_SELECTOR, '#preview_list_area > div:nth-child(1) > div:nth-child(3) > button').click()70else:print('something wrong')71#ììì ì¶ê°72#ìëì
ë ¥ í´ë¦73dvr.find_element(By.CSS_SELECTOR, '#direct_member').click()74#ì´ë¦, ë©ì¼, ë²í¸ ì
ë ¥75dvr.find_element(By.CSS_SELECTOR, '#add_direct_user_list_div > tr:nth-child(1) > td:nth-child(2) > input').send_keys('test')76dvr.find_element(By.CSS_SELECTOR, '#add_direct_user_list_div > tr:nth-child(1) > td:nth-child(3) > input').send_keys('test@saramin.co.kr')77dvr.find_element(By.CSS_SELECTOR, '#add_direct_user_list_div > tr:nth-child(1) > td:nth-child(4) > input').send_keys('010-0000-0000')78#ììì ì¶ê° ë²í¼ í´ë¦79dvr.find_element(By.CSS_SELECTOR, '#btn_add_user').click()80time.sleep(1)81dvr.switch_to.alert.accept()82#ìì id, ë¹ë² ë°ì¤ê¸°83# ì¸ì ì± ê´ë¦¬ ìì¸íì´ì§ ì´ì´ì¼í¨ >> ì¸ì ì± ê´ë¦¬ 리ì¤í¸ìì ê°ì¥ ìµê·¼ ê²ì¬ë¡ ê° ì ìë ì¹ ìë¦¬ë¨¼í¸ ì í > í´ë¹ ì리먼í¸ì href ìì±ì ê°ì ê°ì ¸ì¤ê³ (Strí), ëìì 6ì리 ì¬ë¼ì´ì¤84href=dvr.find_element(By.CSS_SELECTOR, '#preview_list_area > div:nth-child(1) > div.item.left > div > div.title > h2 > span > a').get_attribute('href')85exam_seq=href[-6:]86url2='https://www.saramin.co.kr/zf_user/memcom/preview/user-list?page_count=5&siat_exam_seq='87dvr.get(url2+exam_seq)88# ê²ì¬ id, ë¹ë² ì ì¥89exam_id=dvr.find_element(By.CSS_SELECTOR, '#preview_user_list_area > div.tblSticky > table > tbody > tr > td:nth-child(5)').text90exam_cert=dvr.find_element(By.CSS_SELECTOR, '#preview_user_list_area > div.tblSticky > table > tbody > tr > td:nth-child(6)').text91#--------------------------ììì ë±ë¡ ë---------------------------------------92# siat íì´ì§ ì´ë+ë¡ê·¸ì¸93dvr.get('https://www.saramin.co.kr/zf_user/siat')94dvr.find_element(By.CSS_SELECTOR, '#auth_id').send_keys(exam_id)95dvr.find_element(By.CSS_SELECTOR, '#auth_pw').send_keys(exam_cert)96dvr.find_element(By.CSS_SELECTOR, '#authForm > div.box_btn > button').click()97time.sleep(1)98dvr.find_element(By.CSS_SELECTOR, '#career_type_0').send_keys(Keys.SPACE)99dvr.find_element(By.CSS_SELECTOR, '#job').click()100dvr.find_element(By.XPATH, '//*[@id="job"]/option[2]').click()101dvr.find_element(By.CSS_SELECTOR, '#agree_chk').send_keys(Keys.SPACE)102dvr.find_element(By.CSS_SELECTOR, '#exam_next').click()103dvr.find_element(By.CSS_SELECTOR, '#start_exam').click()104# íì´ì§ íëì© ë기기105# for i in range(1,10) :106# dvr.find_element(By.CSS_SELECTOR, '#next_exam_button').click()107dvr.find_element(By.CSS_SELECTOR, '#immediately_move_span_60 > button').click()108time.sleep(0.5)109dvr.find_element(By.CSS_SELECTOR, '#complete_exam_button').click()110dvr.switch_to.alert.accept()111#-------ì¸ì±ê²ì¬ ìì---------112dvr.find_element(By.CSS_SELECTOR, '#start_exam').click()113# ì ë¶ 'ìëë¤' ì²´í¬íëë¡ ë§ë¦114# ê° ë²í¼ì ìì´ëë 'answer_expl_'+ë²í¸ì´ë©°, +4ëë í¨í´ >> a ì´ê¸°ê° ë£ê³ 4ì© ëë ¤ê°ë©´ì ì°ëë¡115a=2719116for i in range(1,16):117 118 for i in range(1,11):119 sel='answer_expl_'+str(a)120 dvr.find_element(By.ID, sel).send_keys(Keys.SPACE)121 a+=4122 # ì¤ê°ì¤ê° 문ì ê° ìì ëìëì§ ëë½ë ë²í¸ê° ìì >> í ë² ë ì
ë°ì´í¸í´ì ë¤ì 문ì ë르ëë¡123 if a==3199:124 a+=4125 elif a==3275:126 a+=4127 128 elif a==3295:129 a+=4130 elif a==3303:131 a+=4 132 133 time.sleep(0.3)134 # aê°ì ì²´í¬í´ì ë§ì§ë§ 문ì ê° ì²´í¬ëììì§ íì¸(aê° ë§ì§ë§ 문ì 'ìëì¤' ë²í¼ì ë²í¸ë³´ë¤ ììì§ íì¸) > ì²´í¬ê° ëìë¤ë©´ ì ì¶ ë²í¼ í´ë¦, ìëë¼ë©´ ë¤ì ë²í¼ í´ë¦135 if a<3331:136 dvr.find_element(By.CSS_SELECTOR, '#next_exam_button').click()137 try:138 dvr.switch_to.alert.accept()139 dvr.find_element(By.CSS_SELECTOR, '#next_exam_button').click()140 except:pass141 142 else: dvr.find_element(By.CSS_SELECTOR, '#complete_exam_button').click() 143 time.sleep(0.3)...
test_endtoend.py
Source:test_endtoend.py
...25 #connect to web application26 self.driver.get("http://localhost:3000/")27 self.driver.set_window_size(1920, 1040)28 #Sign in29 self.driver.find_element(By.CSS_SELECTOR, ".text-center").click()30 self.driver.find_element(By.NAME, "email").click()31 self.driver.find_element(By.NAME, "email").send_keys("ryangreen@gmail.com")32 self.driver.find_element(By.NAME, "password").click()33 self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(2) > div:nth-child(1)").click()34 self.driver.find_element(By.NAME, "password").send_keys("testing123")35 self.driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(5)").click()36 self.driver.implicitly_wait(2)37 #Add horse38 self.driver.find_element(By.LINK_TEXT, "Dashboard").click()39 self.driver.find_element(By.LINK_TEXT, "Add Horses").click()40 self.driver.find_element(By.NAME, "horse_name").click()41 self.driver.find_element(By.NAME, "horse_name").send_keys("test horse")42 self.driver.find_element(By.NAME, "passport_no").click()43 self.driver.find_element(By.NAME, "passport_no").send_keys("122223333444444")44 self.driver.find_element(By.NAME, "weight_kg").click()45 self.driver.find_element(By.NAME, "weight_kg").send_keys("200")46 self.driver.find_element(By.NAME, "height_cm").click()47 self.driver.find_element(By.NAME, "height_cm").send_keys("180")48 self.driver.find_element(By.NAME, "colour").click()49 self.driver.find_element(By.NAME, "colour").send_keys("test")50 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(3) > .form-group:nth-child(2) > .form-control").click()51 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(3) > .form-group:nth-child(2) > .form-control").send_keys("test")52 self.driver.find_element(By.NAME, "horse_breed").click()53 self.driver.find_element(By.NAME, "horse_breed").send_keys("test")54 self.driver.find_element(By.NAME, "client_name").click()55 self.driver.find_element(By.NAME, "client_name").send_keys("test")56 self.driver.find_element(By.LINK_TEXT, "Add Horse").click()57 #make prediction58 self.driver.find_element(By.LINK_TEXT, "Home").click()59 element = self.driver.find_element(By.LINK_TEXT, "Home")60 actions = ActionChains(self.driver)61 actions.move_to_element(element).perform()62 element = self.driver.find_element(By.CSS_SELECTOR, "body")63 actions = ActionChains(self.driver)64 self.driver.find_element(By.NAME, "horse_id").click()65 dropdown = self.driver.find_element(By.NAME, "horse_id")66 dropdown.find_element(By.XPATH, "option['test horse // 122223333444444 // test']").click()67 self.driver.find_element(By.CSS_SELECTOR, ".btn-success").click()68 element = self.driver.find_element(By.CSS_SELECTOR, ".btn-success")69 actions = ActionChains(self.driver)70 actions.move_to_element(element).perform()71 self.driver.find_element(By.CSS_SELECTOR, ".btn-warning").click()72 #see individual horse prediction & download csv73 self.driver.find_element(By.LINK_TEXT, "Dashboard").click()74 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(11) > .btn").click()75 self.driver.find_element(By.LINK_TEXT, "Download me").click()76 self.driver.find_element(By.CSS_SELECTOR, ".btn-default").click()77 element = self.driver.find_element(By.CSS_SELECTOR, ".btn-default")78 actions = ActionChains(self.driver)79 actions.move_to_element(element).perform()80 #see the account prediction history81 self.driver.find_element(By.LINK_TEXT, "See Prediction History").click()82 #edit horse83 self.driver.find_element(By.LINK_TEXT, "Dashboard").click()84 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(12) > .btn").click()85 self.driver.find_element(By.CSS_SELECTOR, ".userInfo > div").click()86 self.driver.find_element(By.NAME, "horse_name").send_keys("edit")87 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(1)").click()88 self.driver.find_element(By.NAME, "passport_no").send_keys("444444444444444")89 self.driver.find_element(By.CSS_SELECTOR, ".container > div > .container").click()90 self.driver.find_element(By.NAME, "weight_kg").send_keys("300")91 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(2)").click()92 self.driver.find_element(By.NAME, "height_cm").send_keys("177")93 self.driver.find_element(By.CSS_SELECTOR, ".container > div > .container").click()94 self.driver.find_element(By.NAME, "colour").send_keys("edit")95 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(3)").click()96 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(3) > .form-group:nth-child(2) > .form-control").send_keys("edit")97 self.driver.find_element(By.CSS_SELECTOR, ".container > div > .container").click()98 self.driver.find_element(By.NAME, "horse_breed").send_keys("edit")99 self.driver.find_element(By.CSS_SELECTOR, ".form-row:nth-child(4)").click()100 self.driver.find_element(By.NAME, "client_name").send_keys("edit")101 self.driver.find_element(By.CSS_SELECTOR, ".btn-success").click()102 #change status of horse x3103 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(14) > .btn").click()104 self.driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(2)").click()105 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(14) > .btn").click()106 self.driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(3)").click()107 #delete horse108 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(14) > .btn").click()109 self.driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(4)").click()110 self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(4) > td:nth-child(13) > .btn").click()111 #logout112 self.driver.find_element(By.LINK_TEXT, "Logout").click()...
AddCustomePage.py
Source:AddCustomePage.py
...30 __SuccessMessage_xpath = (By.XPATH, "//div[@class='alert alert-success alert-dismissable']")31 def __init__(self, driver):32 super().__init__(driver)33 def clickCustomers(self):34 self.driver.find_element(*addCustomer.__link_customer_xpath).click()35 def clickCustomersMenu(self):36 self.elementToClickable(self.__link_customer_menu_xpath)37 self.driver.find_element(*addCustomer.__link_customer_menu_xpath).click()38 def addNew(self):39 self.driver.find_element(*addCustomer.__Add_new_xpath).click()40 def setEmail(self, email):41 self.driver.find_element(*addCustomer.__Email_box_css).clear()42 self.driver.find_element(*addCustomer.__Email_box_css).send_keys(email)43 def setPassword(self, password):44 self.driver.find_element(*addCustomer.__Password_box_id).clear()45 self.driver.find_element(*addCustomer.__Password_box_id).send_keys(password)46 def setFirstName(self, FirstName):47 self.driver.find_element(*addCustomer.__FirstName_box_css).clear()48 self.driver.find_element(*addCustomer.__FirstName_box_css).send_keys(FirstName)49 def setLastName(self, LastName):50 self.driver.find_element(*addCustomer.__LastName_box_css).clear()51 self.driver.find_element(*addCustomer.__LastName_box_css).send_keys(LastName)52 def setDOB(self, dob):53 self.driver.find_element(*addCustomer.__DOB_box_id).clear()54 self.driver.find_element(*addCustomer.__DOB_box_id).send_keys(dob)55 def setCompany(self, company):56 self.driver.find_element(*addCustomer.__Company_box_id).clear()57 self.driver.find_element(*addCustomer.__Company_box_id).send_keys(company)58 def clickTaxExempt(self):59 self.driver.find_element(*addCustomer.__tax_exempt_click_id).click()60 def setCustomerRoles(self, role):61 self.driver.find_element(*addCustomer.__customerRole_xpath).click()62 if role == "Registered":63 self.elementToClickable(self.__Registered_xpath)64 self.listItem = self.driver.find_element(*addCustomer.__Registered_xpath)65 elif role == "Administrator":66 self.elementToClickable(self.__Administrator_xpath)67 self.listItem = self.driver.find_element(*addCustomer.__Administrator_xpath)68 elif role == "Guests":69 self.driver.find_element_by_xpath("//*[@id='SelectedCustomerRoleIds_taglist']/li/span[2]").click()70 self.listItem = self.driver.find_element(*addCustomer.__Guest_xpath)71 elif role == "Vendors":72 self.listItem = self.driver.find_element(*addCustomer.__Vendors_xpath)73 self.driver.execute_script("arguments[0].click();", self.listItem)74 def setManagerVendor(self, value):75 element = self.driver.find_element(*addCustomer.__vendor_box_css)76 drp = Select(element)77 drp.select_by_visible_text(value)78 def setGender(self, gender):79 if gender == "Male":80 self.driver.find_element(*addCustomer.__Gender_Male_id).click()81 elif gender == "Female":82 self.driver.find_element(*addCustomer.__Gender_Female_id).click()83 def setAdminComment(self, comment):84 self.driver.find_element(*addCustomer.__Admin_comment_css).send_keys(comment)85 def clickSave(self):86 self.driver.find_element(*addCustomer.__Save_xpath).click()87 def verifyAddCustomerTest(self):...
RegisterPage.py
Source:RegisterPage.py
...31 # è°ç¨pageä¸ç_openæå¼è¿æ¥32 self._open(self.base_url)33 # è¾å
¥ç¨æ·åï¼è°ç¨send_keys对象ï¼è¾å
¥ç¨æ·å34 def input_danweiname(self, danweiname):35 # self.find_element(*self.username_loc).clear()36 self.find_element(*self.danweiname_loc).send_keys(str(danweiname))37 # def select_province(self, province):38 # # self.find_element(*self.username_loc).clear()39 # self.find_element(*self.province_loc).click()40 # self.find_element(*(By.XPATH, self.province2_loc_value+str(province)+']')).click()41 #42 # def select_city(self, city):43 # # self.find_element(*self.username_loc).clear()44 # self.find_element(*self.city_loc).click()45 # self.find_element(*(By.XPATH, self.city2_loc_value+str(city)+']')).click()46 #47 # def select_area(self, area):48 # # self.find_element(*self.username_loc).clear()49 # self.find_element(*self.area_loc).click()50 # self.find_element(*(By.XPATH, self.area2_loc_value+str(area)+']')).click()51 #52 # def input_email(self, email):53 # # self.find_element(*self.username_loc).clear()54 # self.find_element(*self.email_loc).send_keys(str(email))55 #56 # def input_username(self, username):57 # # self.find_element(*self.username_loc).clear()58 # self.find_element(*self.username_loc).send_keys(str(username))59 #60 # def input_phonenum(self, phonenum):61 # # self.find_element(*self.username_loc).clear()62 # self.find_element(*self.phonenum_loc).send_keys(str(phonenum))63 #64 # def input_password1(self, password1):65 # # self.find_element(*self.username_loc).clear()66 # self.find_element(*self.password1_loc).send_keys(str(password1))67 #68 # def input_password2(self, password2):69 # # self.find_element(*self.username_loc).clear()70 # self.find_element(*self.password2_loc).send_keys(str(password2))71 #72 # def click_registerbutton(self):73 # # self.find_element(*self.username_loc).clear()74 # self.find_element(*self.registerbutton_loc).click()75 #76 # def is_sussess(self):77 # actualval = self.find_element(*self.assert_loc).text78 # return actualval79 # # ç¨æ·åæå¯ç ä¸åçæ¯Tipæ¡å
容å±ç¤º80 # def show_span(self):81 # return self.find_element(*self.span_loc).text82 #83 # # åæ¢ç»å½æ¨¡å¼ä¸ºå¨æå¯ç ç»å½ï¼IEä¸ææï¼84 # def swich_DynPw(self):85 # self.find_element(*self.dynpw_loc).click()86 #87 # # ç»å½æå页é¢ä¸çç¨æ·IDæ¥æ¾88 # def show_userid(self):...
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!!