Best Python code snippet using playwright-python
Getir.py
Source:Getir.py
...54 self.get_sub_category_from_web(category)55 def get_category_from_web(self):56 category_name = []57 self.page.goto(gv.GETIR_HOME)58 section_class_category = self.page.query_selector(59 'section[class^=style__CategoriesWrapper]')60 if section_class_category != None:61 html = section_class_category.inner_html()62 soup = BeautifulSoup(html, "html.parser")63 all_categories = soup.find_all("span")64 for category in all_categories:65 if (category.text != "") and (category.text not in category_name):66 category_name.append(category.text)67 for category in category_name:68 if self.database.get_category_with_name(category) == None:69 category_obj = Category(name=category)70 self.database.add_category(category_obj)71 logging.info(f"Category {category} added to database")72 self.load_category_from_db()73 def get_sub_category_from_web(self, category: Category):74 if (self.page.url == gv.GETIR_HOME):75 self.page.click(f'img[alt="{category.name}"]')76 dongu = True77 while dongu:78 all_query = self.page.query_selector_all(79 "div[data-testid='breadcrumb-item']")80 for query in all_query:81 if (query.inner_text() == category.name):82 dongu = False83 panel_body = self.page.query_selector(84 'div[data-testid="panel-body"]')85 if panel_body != None:86 html = panel_body.inner_html()87 soup = BeautifulSoup(html, "html.parser")88 all_sub_categories = soup.find_all("a")89 for sub_category in all_sub_categories:90 sub_category_span = sub_category.select(91 'span[data-testid="text"]')[0].text92 if self.database.get_sub_category_with_id_name(category.id, sub_category_span) == None:93 sub_category_obj = SubCategory(name=sub_category_span)94 self.database.add_sub_category(95 sub_category_obj, category)96 logging.info(97 f"Sub Category {sub_category_span} added to database")98 elif ("https://getir.com/kategori/" in self.page.url):99 collapse_div = self.page.query_selector(100 'div[data-testid="collapse"]')101 panel_divs = collapse_div.query_selector_all(102 'div[data-testid="panel"]')103 for panel_div in panel_divs:104 span_text = panel_div.query_selector(105 'span[data-testid="text"]').inner_text()106 if span_text == category.name:107 panel_div.click()108 panel_body = panel_div.query_selector(109 'div[data-testid="panel-body"]')110 if panel_body != None:111 html = panel_body.inner_html()112 soup = BeautifulSoup(html, "html.parser")113 all_sub_categories = soup.find_all("a")114 for sub_category in all_sub_categories:115 sub_category_span = sub_category.select(116 'span[data-testid="text"]')[0].text117 if self.database.get_sub_category_with_id_name(category.id, sub_category_span) == None:118 sub_category_obj = SubCategory(119 name=sub_category_span)120 self.database.add_sub_category(121 sub_category_obj, category)122 logging.info(123 f"Sub Category {sub_category_span} added to database")124 break125 else:126 self.page.goto(gv.GETIR_HOME)127 self.get_sub_category_from_web(category)128 def get_sub_categories_with_category(self, category: Category) -> List[SubCategory]:129 return self.database.get_sub_categories(category)130 def get_getir_all_sub_category(self):131 for category in self.category_list:132 self.get_sub_category_from_web(category)133 def go_category(self, category: Category):134 if (self.page.url == gv.GETIR_HOME):135 # home screen136 self.page.click(f'img[alt="{category.name}"]')137 sleep(2) # WAÄ°T FOR PAGE LOAD WÄ°TH PLAYWRIGHT NOT TIME.SLEEP138 self.page.query_selector(139 "div[name='category-products']").wait_for_element_state("visible")140 all_query = self.page.query_selector_all(141 "div[data-testid='breadcrumb-item']")142 for query in all_query:143 if (query.inner_text() == category.name):144 break145 # dongu = True146 # while dongu:147 # all_query = self.page.query_selector_all("div[data-testid='breadcrumb-item']")148 # for query in all_query:149 # if (query.inner_text() == category.name):150 # dongu = False151 elif ("https://getir.com/kategori/" in self.page.url):152 # category page153 collapse_div = self.page.query_selector(154 'div[data-testid="collapse"]')155 panel_divs = collapse_div.query_selector_all(156 'div[data-testid="panel"]')157 for panel_div in panel_divs:158 span_text = panel_div.query_selector(159 'span[data-testid="text"]').inner_text()160 if span_text == category.name:161 panel_div.click()162 else:163 # not in category page164 self.page.goto(gv.GETIR_HOME)165 self.go_category(category)166 def go_sub_category(self, sub_category: SubCategory):167 category = self.database.get_category_with_sub_category(sub_category)168 if category != None:169 self.go_category(category)170 collapse_div = self.page.query_selector(171 'div[data-testid="collapse"]')172 panel_divs = collapse_div.query_selector_all(173 'div[data-testid="panel"]')174 for panel_div in panel_divs:175 span_text = panel_div.query_selector(176 'span[data-testid="text"]').inner_text()177 if span_text == category.name:178 panel_body = panel_div.query_selector(179 'div[data-testid="panel-body"]')180 if panel_body != None:181 a_list = panel_body.query_selector_all('a')182 for a in a_list:183 span_text = a.query_selector(184 'span[data-testid="text"]').inner_text()185 if span_text == sub_category.name:186 a.click()187 break188 def clear_text_for_sql_injection(self, text: str) -> str:189 return text.replace("'", "").replace('"', "").replace("\\", "").replace("'", "").replace("é", "")190 def clear_price(self, price: str) -> float:191 return float(price.replace("âº", "").replace(",", "."))192 def get_all_getir_products(self, pass_yeni_urunler : bool = True, pass_indirimler : bool = True, pass_ilginizi_cekebilecekler : bool = True ):193 for category in self.category_list:194 self.page.goto(gv.GOOGLE)195 if pass_yeni_urunler and category.name == "Yeni Ãrünler":196 print("Pass Yeni Ãrünler")197 pass198 elif pass_indirimler and category.name == "Ä°ndirimler":199 print("Pass Ä°ndirimler")200 pass201 else:202 for sub_category in self.get_sub_categories_with_category(category):203 if pass_ilginizi_cekebilecekler and sub_category.name == "Ä°lginizi Ãekebilecekler":204 print("Pass Ä°lginizi Ãekebilecekler")205 pass206 else:207 self.go_sub_category(sub_category)208 self.get_product_list_web(sub_category)209 def get_card_wrapper(self, sub_category: SubCategory):210 self.page.query_selector(211 "div[name='category-products']").wait_for_element_state("visible")212 213 div_category_products = self.page.query_selector(214 "div[name='category-products']")215 216 div_list = div_category_products.query_selector_all("div")217 for div in div_list:218 header_div = div.query_selector(219 "div[class^='style__HeaderWrapper']")220 if header_div != None:221 h5_text = header_div.query_selector("h5").inner_text()222 if h5_text == sub_category.name:223 card_wrapper = div.query_selector(224 "div[class^='style__CardWrapper']")225 html = card_wrapper.inner_html()226 return html227 elif header_div == None:228 # header_div bulamıyorsan229 breadcrumb_item = self.page.query_selector_all(230 "div[data-testid='breadcrumb-item']")[1].inner_text()231 if breadcrumb_item == sub_category.name:232 print("BULDUM ONU")233 selected_div = div_list[0]234 card_wrapper = selected_div.query_selector(235 "div[class^='style__CardWrapper']")236 html = card_wrapper.inner_html()237 return html238 239 def get_product_list_db(self, sub_category: SubCategory) -> List[Product]:240 return self.database.get_product_w_sub_category(sub_category)241 def get_product_list_web(self, sub_category: SubCategory):242 """Get product list from web page with sub_category"""243 print(f"Getting product list with sub category {sub_category.name}")244 new_product_count = 0245 old_product_count = 0246 247 change_price_count = 0248 249 html = None250 category = self.database.get_category_with_sub_category(sub_category)251 252 if category != None:253 html = self.get_card_wrapper(sub_category)254 #TODO START255 # sub_category_list = category.get_sub_categories()256 257 # selected_index = 0258 # for index, sub_category_f in enumerate(sub_category_list):259 # if (sub_category_f.name == sub_category.name):260 # selected_index = index261 # break262 263 # div_category_products = self.page.query_selector(264 # "div[name='category-products']")265 # div_list = div_category_products.query_selector_all("div")266 # selected_div = div_list[selected_index]267 # card_wrapper = selected_div.query_selector(268 # "div[class^='style__CardWrapper']")269 # if card_wrapper == None:270 # print("wtf")271 # else:272 # html = card_wrapper.inner_html()273 #BU ÅEKÄ°LDE Ä°LK 2 DIVDE ÃALIÅIYOR SONRA ÃALIÅMIYOR FAKAT DAHA HIZLI ÃALIÅIYOR. 274 #TODO STOP275 if html != None:276 soup = BeautifulSoup(html, "html.parser")277 all_product_article = soup.find_all("article")278 for product_article in all_product_article:279 has_discount = False280 discount_price = "0"281 src = product_article.select("img")...
test_grandpy_frontend.py
Source:test_grandpy_frontend.py
...64 self.visit_url()65 assert self.driver.current_url == "http://127.0.0.1:8943/" or self.driver.current_url == "http://localhost:8943/"6667 def send_message(self, message, send=True): 68 self.chat_input = self.query_selector('#input_area')69 self.chat_input.send_keys(message)70 if send: self.query_selector("#submit_button").click()7172@pytest.mark.gpansfe73class TestGrandPyAnswersFrontEndSide(TestMasterClass):7475 @pytest.mark.gpansfe076 def test_if_grandpys_welcome_message_is_correctly_displayed(self):7778 time.sleep(2)79 80 self.message = self.query_selector("#message1")81 self.part_of_expected_answer = "Salut ð, qu'est-ce que je peux faire pour toi ?\n\nTu peux me demander, dans le formulaire juste en bas avec 'Nouveau message' écrit dedans :"8283 assert self.part_of_expected_answer in self.message.text8485 @pytest.mark.gpansfe186 def test_if_grandpy_gives_the_adress_and_the_info_related_to_the_adress_and_if_the_map_is_displayed(self):8788 self.send_message("Connais-tu l'adresse d'OpenClassrooms") 8990 time.sleep(6)9192 self.answer = self.query_selector("#message3")93 self.maps = self.query_selector(".map div.gm-style")94 self.anecdocte = self.query_selector("#message5")9596 assert self.answer.text == "Bien sûr mon poussin ! La voici : \"7 Cité Paradis, 75010 Paris\".\nEt voilà une carte pour t'aider en plus !!"97 assert self.maps.is_displayed98 assert "Mais t'ai-je déjà raconté l'histoire de ce quartier qui m'a vu en culottes courtes ?" in self.anecdocte.text99100 @pytest.mark.gpansfe2101 def test_if_grandpy_greets_back(self):102103 self.chat_input = self.query_selector('#input_area')104 self.chat_input.send_keys('bonjour', Keys.ENTER)105106 time.sleep(2)107108 self.answer = self.query_selector("#message3")109110 assert self.answer.text in ["Bonjour!", "Salut!", "Yo!", "Hi!!", "ð"]111112 @pytest.mark.gpansfe3113 def test_if_grandpy_answers_accordingly_when_asked_for_something_out_of_his_current_scope(self):114115 self.send_message('Garçon !! Je voudrais un verre d\'hydromel, avec 3 glaçons !')116117 time.sleep(2)118119 self.answer = self.query_selector("#message3")120121 assert self.answer.text == "Désolé, je n'ai pas compris ton message... ð Dans une prochaine version peut-être ?"122123 @pytest.mark.gpansfe4124 def test_what_grandpy_says_when_the_user_clicks_on_the_GrandPy_logo(self):125126 self.brand = self.query_selector("#brand_logo > a")127128 self.reactions = {129 0 : "Pourquoi tu appuies sur mon logo, t'es fou ou quoi ? Je suis plus très jeune, c'est fragile ici !!",130 1 : "Mais !?",131 2 : "Ãa va !?",132 3 : "Tu peux arrêter ??",133 4 : "C'EST FINI OUI ?",134 5 : "FRANCHEMENT ?",135 7 : "Aucune empathie hein :/",136 9 : "10 fois de suite... OK. T'as gagné.",137 10: "..."138 }139140 for i in range(11): 141142 self.brand.click()143 time.sleep(2) 144 self.answer = self.query_selector(".grandpy_type:last-child > div")145 146 if i in range(6) or i in [7,10]:147 assert self.answer.text == self.reactions[i]148149@pytest.mark.gpux150class TestUserExperience(TestMasterClass): 151152 @pytest.mark.gpux1153 def test_if_the_message_is_sent_when_the_user_hits_enter(self):154 self.visit_url()155156 self.text_area = self.query_selector('#input_area')157 self.text_area.send_keys('bonjour', Keys.ENTER)158159 time.sleep(2)160161 self.answer = self.query_selector("#message3")162163 assert self.answer.text in ["Bonjour!", "Salut!", "Yo!", "Hi!!", "ð"]164165 @pytest.mark.gpux2166 def test_if_the_loading_animation_is_displayed(self):167 168 time.sleep(0.5)169 self.loading_animation1 = self.query_selector("#animation1")170 assert self.loading_animation1.is_displayed()171172 time.sleep(2)173174 self.send_message("bonjour")175 176 time.sleep(0.5)177 self.loading_animation2 = self.query_selector("#animation3")178 assert self.loading_animation2.is_displayed()179180 @pytest.mark.gpux3181 def test_if_the_last_message_is_always_displayed_to_the_user(self):182183 self.send_message('Bonjour')184 self.send_message('Au revoir')185 self.send_message('Special Feature')186 self.send_message('Wow')187188 time.sleep(2)189190 self.answer = self.query_selector(".message_container:last-child")191192 assert self.answer.rect['y'] <= 660 #Ex de rect : {'height': 18, 'width': 61, 'x': 306, 'y': 4051}. Le message est directement visible si les coordonnées sont inférieures à (très très très grossièrement) à 611.193194 @pytest.mark.gpux4195 def test_if_the_last_message_is_displayed_when_the_user_type_something_in_the_input(self):196197 self.send_message('Bonjour')198 self.send_message('Au revoir')199 self.send_message('Special Feature')200 self.send_message('Wow')201202 time.sleep(1)203204 self.target = self.query_selector("#dialogue_area")205206 while self.query_selector("#message1").rect["y"] < 0:207 ActionChains(self.driver).send_keys_to_element(self.target, Keys.ARROW_UP).perform()208209 self.chat_input = self.query_selector('#input_area')210 self.chat_input.send_keys("message")211212 self.last_message = self.query_selector(".message_container:last-child")213214 time.sleep(1)215216 assert self.last_message.rect['y'] <= 660217218 @pytest.mark.gpux5219 def test_if_the_inputbox_expands_shrinks_when_the_user_adds_and_removes_content_from_it(self):220221 self.chat_input = self.query_selector('#input_area')222223 assert self.chat_input.rect["height"] in range(55,61)224225 self.chat_input.send_keys("H".join(["A" for _ in range (300)]))226227 assert self.chat_input.rect["height"] in range(200,225)228229 while self.chat_input.get_attribute('value'): 230 self.chat_input.send_keys(Keys.BACKSPACE)231
...
schedule.py
Source:schedule.py
...11 def element_select(self, forName, selectName='.el-select', options='1'):12 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡13 self.execute_script('$("body>.el-popper.el-select-dropdown").remove()')14 # ç¹å» å¼¹åºéæ©æ¡15 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()16 # éæ© ç¬¬ä¸é¡¹17 self.query_selector(18 'body>.el-popper.el-select-dropdown .el-select-dropdown__item:nth-child(' + options[0] + ')').click()19 def element_more_select(self, forName, selectName='.el-select', options='1'):20 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡21 self.execute_script('$("body>.el-popper.el-select-dropdown").remove()')22 # ç¹å» å¼¹åºéæ©æ¡23 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()24 # å¤ä¸ªéæ©25 for nthChild in options:26 if nthChild is not ',':27 self.element_click('ç¹å»ç¬¬{}å¨'.format(nthChild),28 'body>.el-popper.el-select-dropdown .el-select-dropdown__item:nth-child({})'.format(29 nthChild), times=1)30 def element_cascader(self, forName, selectName='.el-cascader', options='1,1'):31 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡32 self.execute_script('$("body>.el-popper.el-cascader__dropdown").remove()')33 # ç¹å» å¼¹åºéæ©æ¡34 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()35 # éæ© ç¬¬ä¸é¡¹36 self.query_selector(37 'body>.el-popper.el-cascader__dropdown .el-cascader-menu:nth-child(1) .el-cascader-node__label:nth-child(' +38 options[0] + ')').click()39 self.element_click('ç¹å»_' + forName + '_æé®',40 'body>.el-popper.el-cascader__dropdown .el-cascader-menu:nth-child(2) .el-cascader-node__label:nth-child(' +41 options[2] + ')', times=1)42 def element_picker_panel(self, forName, selectName='.el-date-editor'):43 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡44 self.execute_script('$("body>.el-popper.el-picker-panel").remove()')45 # ç¹å» å¼¹åºéæ©æ¡46 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()47 # éæ© ä»å¤©çåä¸å¤©48 self.query_selector('body>.el-popper.el-picker-panel .today+.available').click()49 def schedule(self, clName):50 self.wait_time(1)51 # ç¹å»è¿å
¥ æ ¡å¡èå52 self.element_click('ç¹å»é¡¶é¨_æ ¡å¡_æé®', '#tab-0', times=1)53 # ä¼ ééè¦åå54 self.button_show_click(["æ ¡å¡ç®¡ç", "课ç¨ç®¡ç", "ç级管ç"])55 # loading å è½½ç¶æ56 self.check_not_display('ç级 loading å è½½', '.view .el-loading-mask', times=2)57 if clName is not None:58 # æç´¢ ç级 className59 self.query_selector('.view input[placeholder="请è¾å
¥ç级å称"]').send_keys(clName)60 # çå¾
å
ç´ åºç°61 self.check_displayed('çå¾
æ课æé®åºç°', '.view .el-table__fixed-right tr:nth-child(1) td .operation-part .el-button',62 times=2)63 # éæ©æ课64 allButton = self.query_selector_all('.view .el-table__fixed-right tr:nth-child(1) td .operation-part .el-button')65 # ç¡®å®åºç¡æä½æé® ä¸º 4 个66 if len(allButton) is not 4:67 print('{}-ç级ï¼å·²ç»æè¿è¯¾'.format(clName))68 return clName69 print(allButton[2].get_attribute('textContent'), '=========textContent')70 # ç¹å»æ课æé®71 allButton[2].click()72 # éæ© ä¸è¯¾å¨æ é»è®¤éæ©å个73 self.element_more_select(forName='attendClassWeeks', options='1,2,3,4')74 # éæ© éæ©ä¸è¯¾æ¶é´æ®µ75 # self.query_selector('label[for="classHours"]+.el-form-item__content .el-select ').click()76 # éæ© å®å¶æ¶é´77 self.query_selector('.customizingtime').click()78 # å é¤ æ æ³éä¸çå
容79 self.execute_script('$("body>.el-time-range-picker.el-popper").remove()')80 # æå¼ å®å¶æ¶é´ å¼¹çª81 self.query_selector('.el-dialog[aria-label="å®å¶æ¶é´"] .el-date-editor').click()82 # å¼å§æ¶é´ 17 ç¹83 self.query_selector('body>.el-time-range-picker.el-popper .el-time-spinner__list .el-time-spinner__item:nth-child(18)').click()84 # ç¹å»ç¡®è®¤85 self.query_selector('body>.el-time-range-picker.el-popper .el-time-panel__footer .confirm').click()86 # å
³é å®å¶æ¶é´ å¼¹çª87 self.query_selector('.el-dialog[aria-label="å®å¶æ¶é´"] .dialog-footer .el-button:nth-child(2)').click()88 # çææ课89 self.query_selector('.view .add-top .el-row:nth-child(4) .el-button').click()90 # çå¾
çææ课91 self.check_displayed('æ¯å¦çææ课', '.view .mind_list .table .tab_li:nth-child(2)', times=2)92 # ä¿åæ课93 self.query_selector('.view .create_btn .el-button:nth-child(2)').click()94 # æ¯å¦åå¨ aria-label="èå¸è¢«å
¶ä»æ课å ç¨"95 self.element_click('èå¸è¢«å
¶ä»æ课å ç¨', '.el-message-box__wrapper[aria-label="èå¸è¢«å
¶ä»æ课å ç¨"] .el-button--primary', times=3)96# åç¬æµè¯æ¶ 使ç¨97if __name__ == '__main__':98 # print(os.path.abspath('../ice.png'))99 #100 driverAddStudent = init_drives('https://uat-edurp.ambow.com/',101 "../../../myproject/testSeleuim/chromedriver_win32/chromedriver.exe")102 Login(driverAddStudent).xiao_wu_login('wei.xia@ambow.com', 'Ambow88888888')103 # å
¨å±å¹104 driverAddStudent.maximize_window()105 # æ°å¢å¦ç106 studentName = AddStudent(driverAddStudent).add_student()107 # æ°å¢ç级...
addClass.py
Source:addClass.py
...10 def element_select(self, forName, selectName='.el-select', options='1', otherSelect=None):11 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡12 self.execute_script('$("body>.el-popper.el-select-dropdown").remove()')13 # ç¹å» å¼¹åºéæ©æ¡14 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()15 # å¡«å
¥èå¸16 if otherSelect is not None:17 self.check_displayed('éæ©èå¸',18 'body>.el-popper.el-select-dropdown .el-select-dropdown__item:nth-child(' + options[19 0] + ')', times=2)20 # éæ©æå®é项21 self.query_selector(22 'label[for="' + forName + '"]+.el-form-item__content ' + selectName + ' .el-input__inner').send_keys(23 otherSelect)24 self.query_selector(25 'body>.el-select-dropdown.el-popper .el-select-dropdown__item:not([style="display: none;"])').click()26 else:27 # éæ© ç¬¬ä¸é¡¹28 self.element_click(29 'body>.el-popper.el-select-dropdown .el-select-dropdown__item:nth-child(' + options[0] + ')').click()30 def element_cascader(self, forName, selectName='.el-cascader', options='1,1'):31 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡32 self.execute_script('$("body>.el-popper.el-cascader__dropdown").remove()')33 # ç¹å» å¼¹åºéæ©æ¡34 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()35 # éæ© ç¬¬ä¸é¡¹36 self.query_selector(37 'body>.el-popper.el-cascader__dropdown .el-cascader-menu:nth-child(1) .el-cascader-node__label:nth-child(' +38 options[0] + ')').click()39 self.element_click('ç¹å»_' + forName + '_æé®',40 'body>.el-popper.el-cascader__dropdown .el-cascader-menu:nth-child(2) .el-cascader-node__label:nth-child(' +41 options[2] + ')', times=1)42 def element_picker_panel(self, forName, selectName='.el-date-editor'):43 # å é¤ææå¯ä»¥è¢«éæ©çä¸ææ¡44 self.execute_script('$("body>.el-popper.el-picker-panel").remove()')45 # ç¹å» å¼¹åºéæ©æ¡46 self.query_selector('label[for="' + forName + '"]+.el-form-item__content ' + selectName).click()47 # éæ© ä»å¤©çåä¸å¤©48 # self.query_selector('body>.el-popper.el-picker-panel .today+.available').click()49 # æä¸åä¸å¹´50 self.query_selector('body>.el-popper.el-picker-panel .el-date-picker__header button[aria-label="åä¸å¹´"]').click()51 # éæ©å»å¹´çå½æç第ä¸å¤©52 self.query_selector('body>.el-popper.el-picker-panel .el-picker-panel__content .available').click()53 def add_class(self, teacherName='æè'):54 self.wait_time(1)55 # ç¹å»è¿å
¥ æ ¡å¡èå56 self.element_click('ç¹å»é¡¶é¨_æ ¡å¡_æé®', '#tab-0', times=3)57 # ä¼ ééè¦åå58 self.button_show_click(["æ ¡å¡ç®¡ç", "课ç¨ç®¡ç", "ç级管ç"])59 # æ°å¢ç级 æé®60 if self.element_click('æ°å¢ç级_æé®', '.view .el-button', times=3) is None:61 # æ°å¢ç级ç¹å» é误æ
åµä¸62 self.element_click('æ°å¢ç级_æé®', '.view .el-button', times=3)63 # éæ© æ ¡åº64 self.element_cascader(forName='orgId', options='1,1')65 # éæ© ç«é¡¹ç¼å·66 self.element_select(forName='subjectCode', options='1')67 # éæ© è¯¾ç¨å称68 self.element_select(forName='edaCourseCode', options='4')69 # éæ© ä»»è¯¾èå¸70 self.element_select(forName='teacherId', options='4', otherSelect=teacherName)71 # éæ© å¼è¯¾æ¶é´72 self.element_picker_panel(forName='openingTime')73 # æ·»å ç级å称åç¼74 classNameSuffix = self.fake.name()75 self.query_selector('label[for="classCourseNameAfter"]+.el-form-item__content .el-input__inner').send_keys(76 classNameSuffix)77 self.query_selector('body').click()78 # ä¿åç级åå79 classCourseName = self.query_selector(80 'label[for="classCourseName"]+.el-form-item__content .el-input__inner').get_attribute('value')81 # ç¹å»ä¿åæé®82 self.query_selector('.view .el-button:last-child').click()83 # å
³éå½åæ ç¾84 # self.close_tag()85 # è¿åç级åå86 print('æ°å»ºç级åå为:{}.'.format(classCourseName))87 return classCourseName88# åç¬æµè¯æ¶ 使ç¨89if __name__ == '__main__':90 # print(os.path.abspath('../ice.png'))91 #92 driverAddStudent = init_drives('https://uat-edurp.ambow.com/',93 "../../../myproject/testSeleuim/chromedriver_win32/chromedriver.exe")94 Login(driverAddStudent).xiao_wu_login('wei.xia@ambow.com', 'Ambow88888888')95 # å
¨å±å¹96 driverAddStudent.maximize_window()...
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!!