Best Python code snippet using SeleniumBase
test_no_cookies.py
Source:test_no_cookies.py
...51 '//span[@class="b-header-b-personal-e-icon-count-m-cart basket-in-cart-a"]')52 assert basket_items.text == '0'5354 def test_page_bottom_menu_link_covid(self):55 scroll_to_bottom(pytest.web_driver)56 link_covid = pytest.web_driver.find_element_by_xpath('//a[@class="sprite_kovid kov_desc"]')57 link_covid.click()58 time.sleep(2)59 parent = pytest.web_driver.window_handles[0]60 chld = pytest.web_driver.window_handles[1]61 pytest.web_driver.switch_to.window(chld)62 title = pytest.web_driver.title63 assert title == 'E-commerce пÑоÑив COVID'64 pytest.web_driver.close()65 pytest.web_driver.switch_to.window(parent)6667 # def test_page_bottom_menu_link_akit(self):68 # scroll_to_bottom(pytest.web_driver)69 # link_akit = '//li[@class="b-rfooter-e-item"]/a[@href="//www.labirint.org/vakansii?tab=5"]'70 # hover_move_click(pytest.web_driver, link_akit)71 # # pytest.web_driver.find_element_by_xpath('//li/a[@href="//www.labirint.org/vakansii?tab=5"]').click()72 # # link_akit.click()73 # time.sleep(5)74 # title = pytest.web_driver.title75 # assert title == 'ÐолÑзоваÑелÑÑкое СоглаÑение об ÑÑловиÑÑ
пÑедоÑÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ Ð£ÑлÑг в инÑеÑнеÑ-магазине ' \76 # 'ÐабиÑÐ¸Ð½Ñ | ÐабиÑинÑ'777879class TestHeaderItems:80 def test_page_messages(self):81 messages = pytest.web_driver.find_element_by_xpath(82 '//li[@class="b-header-b-personal-e-list-item b-header-b-personal-e-list-item-m-md have-dropdown"]')83 messages.click()84 check_form = pytest.web_driver.find_element_by_xpath(85 '//div[@class="js-auth__title new-auth__title"]')86 assert check_form.text == 'ÐолнÑй доÑÑÑп к ÐабиÑинÑÑ'8788 def test_page_my_lab(self):89 my_lab = pytest.web_driver.find_element_by_xpath(90 '//span[@class="b-header-b-personal-e-icon b-header-b-personal-e-icon-m-profile '91 'b-header-e-sprite-background"]')92 my_lab.click()93 check_form = pytest.web_driver.find_element_by_xpath(94 '//div[@class="js-auth__title new-auth__title"]')95 assert check_form.text == 'ÐолнÑй доÑÑÑп к ÐабиÑинÑÑ'9697 def test_page_put_aside(self):98 put_aside = pytest.web_driver.find_element_by_xpath(99 '//span[@class="b-header-b-personal-e-icon-wrapper <!--b-header-b-personal-e-icon-wrapper-m-putorder-->"]')100 put_aside.click()101 active_header = pytest.web_driver.find_element_by_xpath(102 '//li[@class="cabinet-menu__tab cabinet-menu__tab_active"]/a')103 active_link = active_header.get_attribute('href')104 # print('\n', active_link)105 assert active_link == 'https://www.labirint.ru/cabinet/putorder/'106107 def test_page_basket(self):108 basket_link = pytest.web_driver.find_element_by_xpath(109 '//li[@class="b-header-b-personal-e-list-item have-dropdown last-child"]/a').get_attribute('href')110 # print(basket_link)111 open_page(pytest.web_driver, basket_link)112 title = pytest.web_driver.title113 assert title == 'ÐоÑзина. ÐÑовеÑÑÑе заказ. ÐнÑеÑнеÑ-магазин ÐабиÑинÑ.'114115 def test_page_discount_commertial(self):116 discount = pytest.web_driver.find_element_by_xpath(117 '//span[@class="b-header-labelaction-text b-header-b-logo-e-discount-e-text-m-long"]')118 discount.click()119 pytest.web_driver.implicitly_wait(2)120 assert pytest.web_driver.find_element_by_xpath(121 '//div[@class="h2 relative main-block-carousel-title-outer"]').is_displayed()122123124class TestHeaderFirstMenu:125 def test_page_b_menu_books(self):126 books = pytest.web_driver.find_element_by_xpath(127 '//a[@href="/books/"]')128 books.click()129 pytest.web_driver.implicitly_wait(2)130 assert pytest.web_driver.find_element_by_xpath(131 '//h1[@class="genre-name"]').text == "Ðниги"132133 def test_page_b_menu_best(self):134 best = pytest.web_driver.find_element_by_xpath(135 '//a[@href="/best/"]')136 best.click()137 pytest.web_driver.implicitly_wait(2)138 assert pytest.web_driver.find_element_by_xpath(139 '//div[@class="content-block"]/h1').text == "ÐлавнÑе книги 2022"140141 def test_page_b_menu_school(self):142 school = pytest.web_driver.find_element_by_xpath(143 '//a[@href="/school/"]')144 school.click()145 pytest.web_driver.implicitly_wait(2)146 assert pytest.web_driver.find_element_by_xpath(147 '//h1[@class="school-cap__header"]').text == "ÐÑе ÑÑебники в ÐабиÑинÑе"148149 def test_page_b_menu_games(self):150 games = pytest.web_driver.find_element_by_xpath(151 '//a[@href="/games/"]')152 games.click()153 pytest.web_driver.implicitly_wait(2)154 assert pytest.web_driver.find_element_by_xpath(155 '//h1[@class="genre-name"]').text == "ÐгÑÑ Ð¸ игÑÑÑки"156157 def test_page_b_menu_office(self):158 office = pytest.web_driver.find_element_by_xpath(159 '//a[@href="/office/"]')160 office.click()161 pytest.web_driver.implicitly_wait(2)162 assert pytest.web_driver.find_element_by_xpath(163 '//h1[@class="genre-name"]').text == "ÐанÑелÑÑÑкие ÑоваÑÑ"164165 def test_page_b_menu_multimedia(self):166 more_locator = '//span[@class="b-header-b-menu-e-text"]'167 active = '//li[@class="b-menu-second-item active"]'168 hover(pytest.web_driver, more_locator, 0, 25, active)169 assert pytest.web_driver.title == "ÐÐ¾Ð»Ð½Ð°Ñ Ð»Ð¸Ð½ÐµÐ¹ÐºÐ° пÑодÑкÑов мÑлÑÑимедиа | ÐнÑеÑнеÑ-магазин ÐабиÑинÑ"170171 # def test_page_b_menu_multimedia_location():172 # more_locator = '//li[@data-event-content="ÐÑе"]'173 # hidden_link = '//a[@class="b-menu-list-title b-menu-list-title-first" and @href="/multimedia/"]'174 # active = '//li[@class="b-menu-second-item active"]'175 # hover_location(pytest.web_driver, more_locator, hidden_link, active)176 # assert pytest.web_driver.title == "ÐÐ¾Ð»Ð½Ð°Ñ Ð»Ð¸Ð½ÐµÐ¹ÐºÐ° пÑодÑкÑов мÑлÑÑимедиа | ÐнÑеÑнеÑ-магазин ÐабиÑинÑ"177178 def test_page_b_menu_souvenir(self):179 more_locator = '//span[@class="b-header-b-menu-e-text"]'180 active = '//li[@class="b-menu-second-item active"]'181 hover(pytest.web_driver, more_locator, 0, 70, active)182 assert pytest.web_driver.title == "СÑвениÑÑ, Ñамки и алÑÐ±Ð¾Ð¼Ñ Ð´Ð»Ñ ÑоÑогÑаÑий, календаÑи и оÑкÑÑÑки | кÑпиÑÑ Ð¸ " \183 "подаÑиÑÑ Ñ Ð´Ð¾ÑÑавкой | ÐабиÑинÑ"184185 def test_page_b_menu_journals(self):186 more_locator = '//span[@class="b-header-b-menu-e-text"]'187 active = '//li[@class="b-menu-second-item active"]'188 hover(pytest.web_driver, more_locator, 0, 105, active)189 assert pytest.web_driver.find_element_by_xpath(190 '//h1[@class="mag-h1"]').text == "ÐÑÑналÑнÑй лабиÑинÑ"191192 def test_page_b_menu_household(self):193 more_locator = '//span[@class="b-header-b-menu-e-text"]'194 active = '//li[@class="b-menu-second-item active"]'195 hover(pytest.web_driver, more_locator, 0, 145, active)196 assert pytest.web_driver.find_element_by_xpath(197 '//h1[@class="genre-name"]').text == "ТоваÑÑ Ð´Ð»Ñ Ð´Ð¾Ð¼Ð°"198199 def test_page_b_menu_club(self):200 club = pytest.web_driver.find_element_by_xpath(201 '//a[@href="/club/"]')202 club.click()203 title = pytest.web_driver.title204 assert title == 'ÐнижнÑй клÑб инÑеÑнеÑ-магазина ÐабиÑинÑ'205206 def test_page_b_menu_region_location(self):207 region_location = pytest.web_driver.find_element_by_xpath(208 '//span[@class="region-location-icon-txt "]')209 region_location.click()210 city = pytest.web_driver.find_elements_by_xpath('//span[@class="g-alttext-deepblue pointer"]')[8]211 city.click()212 pytest.web_driver.implicitly_wait(2)213 region_location = pytest.web_driver.find_element_by_xpath(214 '//span[@class="region-location-icon-txt "]')215 title = region_location.get_attribute('title')216 assert title == 'ТÑменÑ'217 delivery = pytest.web_driver.find_element_by_xpath(218 '//span[@class="b-header-b-menu-e-text"]/a[@href="/maps/"]')219 delivery.click()220 assert pytest.web_driver.find_element_by_id('js-tab-2').is_displayed()221 pytest.web_driver.back()222 points = pytest.web_driver.find_element_by_xpath(223 '//a[@href="/maps/" and @class="b-header-b-sec-menu-e-link"]')224 points.click()225 assert pytest.web_driver.find_element_by_id('js-tab-2').is_displayed()226227228class TestHeaderSecondMenu:229 def test_page_b_sec_menu_delivery_payment(self):230 delivery_payment = pytest.web_driver.find_element_by_xpath(231 '//a[@href="/help/" and @class="b-header-b-sec-menu-e-link"]')232 delivery_payment.click()233 title = pytest.web_driver.title234 assert title == 'ÐомоÑÑ | ÐабиÑинÑ'235236 def test_page_b_sec_menu_certificates(self):237 certificates = pytest.web_driver.find_element_by_xpath(238 '//a[@href="/top/certificates/" and @class="b-header-b-sec-menu-e-link"]')239 certificates.click()240 title = pytest.web_driver.title241 assert title == 'СеÑÑиÑикаÑÑ'242243 def test_page_b_sec_menu_rating(self):244 rating = pytest.web_driver.find_element_by_xpath(245 '//a[@href="/rating/?id_genre=-1&nrd=1" and @class="b-header-b-sec-menu-e-link"]')246 rating.click()247 title = pytest.web_driver.title248 assert title == 'РейÑинг: лÑÑÑие книги 2022 | ÐабиÑÐ¸Ð½Ñ - РейÑинг'249250 def test_page_b_sec_menu_novelty(self):251 novelty = pytest.web_driver.find_element_by_xpath(252 '//a[@href="/novelty/" and @class="b-header-b-sec-menu-e-link"]')253 novelty.click()254 title = pytest.web_driver.title255 assert title == 'ÐовÑе книги 2022 года | ÐабиÑÐ¸Ð½Ñ - Ðовинки'256257 def test_page_b_sec_menu_discount(self):258 discount = pytest.web_driver.find_element_by_xpath(259 '//a[@href="/sale/" and @class="b-header-b-sec-menu-e-link"]')260 discount.click()261 pytest.web_driver.implicitly_wait(2)262 assert pytest.web_driver.find_element_by_xpath(263 '//div[@class="h2 relative main-block-carousel-title-outer"]').is_displayed()264265 def test_page_b_sec_menu_phone(self):266 phone = pytest.web_driver.find_element_by_xpath(267 '//li[@class="b-header-b-sec-menu-e-list-item have-dropdown have-dropdown-clickable analytics-click-js"]')268 phone.click()269 pytest.web_driver.implicitly_wait(1)270 assert pytest.web_driver.find_elements_by_xpath('//a[@href="#" and @class="btn btn-small btn-clear '271 'font_regular-btn"]')[0].is_displayed()272273 def test_page_b_sec_menu_contact(self):274 contact = pytest.web_driver.find_element_by_xpath(275 '//a[@href="/contact/" and @class="b-header-b-sec-menu-e-link"]')276 contact.click()277 title = pytest.web_driver.title278 assert title == 'ÐонÑакÑÑ ÐºÐ½Ð¸Ð¶Ð½Ð¾Ð³Ð¾ инÑеÑнеÑ-магазина | ÐабиÑинÑ'279280 def test_page_b_sec_menu_support(self):281 support = pytest.web_driver.find_element_by_xpath(282 '//a[@href="/support/" and @class="b-header-b-sec-menu-e-link"]')283 support.click()284 title = pytest.web_driver.title285 assert title == 'СлÑжба поддеÑжки | ÐоддеÑжка лабиÑинÑа'286287 def test_page_b_sec_menu_socials(self):288 socials = '//div[@class="b-header-b-social"]'289 hover_simple(pytest.web_driver, socials)290 assert pytest.web_driver.find_element_by_xpath('//div[@class="popup-window top-block-popup dropdown-block '291 'b-header-b-sec-menu-e-social-popup '292 'dropdown-block-opened"]').is_displayed()293294295class TestPageBottomMenuInPocket: # check bottom links in menu "ÐабиÑÐ¸Ð½Ñ Ð² каÑмане"296 def test_page_bottom_menu_app_store(self):297 scroll_to_bottom(pytest.web_driver)298 app_store = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="App Store"]')299 app_store.click()300 time.sleep(2)301 parent = pytest.web_driver.window_handles[0]302 chld = pytest.web_driver.window_handles[1]303 pytest.web_driver.switch_to.window(chld)304 title = pytest.web_driver.title305 assert title == 'App\xa0Store: ÐабиÑинÑ.ÑÑ â книжнÑй магазин'306 pytest.web_driver.close()307 pytest.web_driver.switch_to.window(parent)308309 def test_page_bottom_menu_goggle_play(self):310 scroll_to_bottom(pytest.web_driver)311 goggle_play = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="Google Play"]')312 goggle_play.click()313 time.sleep(1)314 parent = pytest.web_driver.window_handles[0]315 chld = pytest.web_driver.window_handles[1]316 pytest.web_driver.switch_to.window(chld)317 title = pytest.web_driver.title318 assert title == 'ÐабиÑинÑ.ÑÑ â книжнÑй магазин - Apps on Google Play'319 pytest.web_driver.close()320 pytest.web_driver.switch_to.window(parent)321322 def test_page_bottom_menu_app_gallery(self):323 scroll_to_bottom(pytest.web_driver)324 app_gallery = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="App Gallery"]')325 app_gallery.click()326 time.sleep(10)327 parent = pytest.web_driver.window_handles[0]328 chld = pytest.web_driver.window_handles[1]329 pytest.web_driver.switch_to.window(chld)330 title = pytest.web_driver.title331 assert title == 'AppGallery'332 pytest.web_driver.close()333 pytest.web_driver.switch_to.window(parent)334335336class TestPageBottomMenuSociety: # check bottom links in menu "ÐÑ Ð² ÑоÑÑеÑÑÑ
"337 def test_page_bottom_menu_v_contact(self):338 scroll_to_bottom(pytest.web_driver)339 v_contact = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ÐÐонÑакÑе"]')340 v_contact.click()341 time.sleep(5)342 parent = pytest.web_driver.window_handles[0]343 chld = pytest.web_driver.window_handles[1]344 pytest.web_driver.switch_to.window(chld)345 title = pytest.web_driver.title346 assert title == 'ÐабиÑÐ¸Ð½Ñ | VK'347 pytest.web_driver.close()348 pytest.web_driver.switch_to.window(parent)349350 def test_page_bottom_menu_v_contact_children(self):351 scroll_to_bottom(pytest.web_driver)352 v_contact_children = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ÐÐонÑакÑе. ÐеÑи"]')353 v_contact_children.click()354 time.sleep(5)355 parent = pytest.web_driver.window_handles[0]356 chld = pytest.web_driver.window_handles[1]357 pytest.web_driver.switch_to.window(chld)358 title = pytest.web_driver.title359 assert title == 'ÐабиÑÐ¸Ð½Ñ ÐеÑи | VK'360 pytest.web_driver.close()361 pytest.web_driver.switch_to.window(parent)362363 def test_page_bottom_menu_youtube(self):364 scroll_to_bottom(pytest.web_driver)365 youtube = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ЮÑÑÑб"]')366 youtube.click()367 time.sleep(2)368 parent = pytest.web_driver.window_handles[0]369 chld = pytest.web_driver.window_handles[1]370 pytest.web_driver.switch_to.window(chld)371 title = pytest.web_driver.title372 assert title == 'ÐабиÑÐ¸Ð½Ñ - YouTube'373 pytest.web_driver.close()374 pytest.web_driver.switch_to.window(parent)375376 def test_page_bottom_menu_classmates(self):377 scroll_to_bottom(pytest.web_driver)378 classmates = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ÐдноклаÑÑники"]')379 classmates.click()380 time.sleep(2)381 parent = pytest.web_driver.window_handles[0]382 chld = pytest.web_driver.window_handles[1]383 pytest.web_driver.switch_to.window(chld)384 title = pytest.web_driver.title385 assert title == 'ÐабиÑÐ¸Ð½Ñ | Group on OK | Join, read, and chat on OK!'386 pytest.web_driver.close()387 pytest.web_driver.switch_to.window(parent)388389 def test_page_bottom_menu_dzen(self):390 scroll_to_bottom(pytest.web_driver)391 dzen = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="Ðзен"]')392 dzen.click()393 time.sleep(2)394 parent = pytest.web_driver.window_handles[0]395 chld = pytest.web_driver.window_handles[1]396 pytest.web_driver.switch_to.window(chld)397 title = pytest.web_driver.title398 assert title == 'ÐабиÑÐ¸Ð½Ñ | Zen'399 pytest.web_driver.close()400 pytest.web_driver.switch_to.window(parent)401402 def test_page_bottom_menu_telegram(self):403 scroll_to_bottom(pytest.web_driver)404 telegram = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ТелегÑам"]')405 telegram.click()406 time.sleep(2)407 parent = pytest.web_driver.window_handles[0]408 chld = pytest.web_driver.window_handles[1]409 pytest.web_driver.switch_to.window(chld)410 title = pytest.web_driver.title411 assert title == 'Telegram: Contact @labirintru'412 pytest.web_driver.close()413 pytest.web_driver.switch_to.window(parent)414415 def test_page_bottom_menu_tiktok(self):416 scroll_to_bottom(pytest.web_driver)417 tiktok = pytest.web_driver.find_element_by_xpath('//a[@data-event-content="ТикТок"]')418 tiktok.click()419 time.sleep(2)420 parent = pytest.web_driver.window_handles[0]421 chld = pytest.web_driver.window_handles[1]422 pytest.web_driver.switch_to.window(chld)423 title = pytest.web_driver.title424 assert title == "labirintru (@labirintru) TikTok | Watch labirintru's Newest TikTok Videos"425 pytest.web_driver.close()426 pytest.web_driver.switch_to.window(parent)427428429class TestPageBottomMenuCatalog: # check bottom links in menu "ÐаÑалог"430 def test_page_bottom_menu_allbooks(self):431 scroll_to_bottom(pytest.web_driver)432 allbooks = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a[@data-event-content="ÐÑе '433 'книги"]')434 allbooks.click()435 pytest.web_driver.implicitly_wait(2)436 assert pytest.web_driver.find_element_by_xpath(437 '//h1[@class="genre-name"]').text == "Ðниги"438439 def test_page_bottom_menu_school(self):440 scroll_to_bottom(pytest.web_driver)441 school = pytest.web_driver.find_element_by_xpath(442 '//li[@class="b-rfooter-e-item"]/a[@data-event-content="Школа"]')443 school.click()444 pytest.web_driver.implicitly_wait(2)445 assert pytest.web_driver.find_element_by_xpath(446 '//h1[@class="school-cap__header"]').text == "ÐÑе ÑÑебники в ÐабиÑинÑе"447448 def test_page_bottom_menu_journals(self):449 scroll_to_bottom(pytest.web_driver)450 journals = pytest.web_driver.find_element_by_xpath(451 '//li[@class="b-rfooter-e-item"]/a[@data-event-content="ÐÑÑналÑ"]')452 journals.click()453 pytest.web_driver.implicitly_wait(2)454 assert pytest.web_driver.find_element_by_xpath('//h1[@class="mag-h1"]').text == "ÐÑÑналÑнÑй лабиÑинÑ"455456 def test_page_bottom_menu_games(self):457 scroll_to_bottom(pytest.web_driver)458 games = pytest.web_driver.find_element_by_xpath(459 '//li[@class="b-rfooter-e-item"]/a[@data-event-content="ÐгÑÑÑки"]')460 games.click()461 pytest.web_driver.implicitly_wait(2)462 assert pytest.web_driver.find_element_by_xpath('//h1[@class="genre-name"]').text == "ÐгÑÑ Ð¸ игÑÑÑки"463464 def test_page_bottom_menu_office(self):465 scroll_to_bottom(pytest.web_driver)466 office = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['467 '@data-event-content="ÐанÑÑоваÑÑ"]')468 office.click()469 pytest.web_driver.implicitly_wait(2)470 assert pytest.web_driver.find_element_by_xpath(471 '//h1[@class="genre-name"]').text == "ÐанÑелÑÑÑкие ÑоваÑÑ"472473 def test_page_bottom_menu_multimedia(self):474 scroll_to_bottom(pytest.web_driver)475 multimedia = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['476 '@data-event-content="CD/DVD"]')477 multimedia.click()478 pytest.web_driver.implicitly_wait(2)479 assert pytest.web_driver.title == "ÐÐ¾Ð»Ð½Ð°Ñ Ð»Ð¸Ð½ÐµÐ¹ÐºÐ° пÑодÑкÑов мÑлÑÑимедиа | ÐнÑеÑнеÑ-магазин ÐабиÑинÑ"480481 def test_page_bottom_menu_souvenir(self):482 scroll_to_bottom(pytest.web_driver)483 souvenir = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['484 '@data-event-content="СÑвениÑÑ"]')485 souvenir.click()486 pytest.web_driver.implicitly_wait(2)487 assert pytest.web_driver.title == "СÑвениÑÑ, Ñамки и алÑÐ±Ð¾Ð¼Ñ Ð´Ð»Ñ ÑоÑогÑаÑий, календаÑи и оÑкÑÑÑки | кÑпиÑÑ Ð¸ " \488 "подаÑиÑÑ Ñ Ð´Ð¾ÑÑавкой | ÐабиÑинÑ"489490 def test_page_bottom_menu_household(self):491 scroll_to_bottom(pytest.web_driver)492 household = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['493 '@href="/household/"]')494 household.click()495 pytest.web_driver.implicitly_wait(2)496 assert pytest.web_driver.find_element_by_xpath('//h1[@class="genre-name"]').text == "ТоваÑÑ Ð´Ð»Ñ Ð´Ð¾Ð¼Ð°"497498499class TestPageBottomMenuImportant: # check bottom links in menu "Ðажно"500 def test_page_bottom_menu_actions(self):501 scroll_to_bottom(pytest.web_driver)502 actions = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['503 '@href="/actions/"]')504 actions.click()505 pytest.web_driver.implicitly_wait(2)506 assert pytest.web_driver.title == "ÐкÑии, Ñкидки и\xa0подаÑки в\xa0ÐнÑеÑнеÑ-магазине «ÐабиÑинÑ»."507508 def test_page_bottom_menu_best(self):509 scroll_to_bottom(pytest.web_driver)510 best = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['511 '@data-event-content="ÐлавнÑе книги"]')512 best.click()513 pytest.web_driver.implicitly_wait(2)514 assert pytest.web_driver.find_element_by_xpath(515 '//div[@class="content-block"]/h1').text == "ÐлавнÑе книги 2022"516517 def test_page_bottom_menu_bonus(self):518 scroll_to_bottom(pytest.web_driver)519 bonus = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['520 '@data-event-content="ÐонÑÑ Ð·Ð° ÑеÑензиÑ"]')521 bonus.click()522 pytest.web_driver.implicitly_wait(2)523 assert pytest.web_driver.title == "ÐонÑÑÐ½Ð°Ñ Ð¿ÑогÑамма Ð´Ð»Ñ ÑеÑензенÑов. ÐонÑÑ Ð·Ð° ÑеÑензиÑ"524525 def test_page_bottom_menu_certificates(self):526 scroll_to_bottom(pytest.web_driver)527 certificates = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['528 '@data-event-content="СеÑÑиÑикаÑÑ"]')529 certificates.click()530 pytest.web_driver.implicitly_wait(2)531 assert pytest.web_driver.title == 'СеÑÑиÑикаÑÑ'532533 def test_page_bottom_menu_only_us(self):534 scroll_to_bottom(pytest.web_driver)535 only_us = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['536 '@data-event-content="ТолÑко Ñ Ð½Ð°Ñ"]')537 only_us.click()538 pytest.web_driver.implicitly_wait(2)539 assert pytest.web_driver.title == 'ÐкÑклÑзивнÑе книги | книжнÑй инÑеÑнеÑ-магазин ÐабиÑинÑ'540541 def test_page_bottom_menu_preorder(self):542 scroll_to_bottom(pytest.web_driver)543 preorder = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['544 '@data-event-content="ÐÑедзаказÑ"]')545 preorder.click()546 pytest.web_driver.implicitly_wait(2)547 assert pytest.web_driver.title == 'ÐÑедзаказ. Ðниги, коÑоÑÑе Ð¼Ñ Ð¶Ð´ÐµÐ¼'548549550class TestPageBottomMenuInteresting: # check bottom links in menu "ÐнÑеÑеÑно"551 def test_page_bottom_menu_now(self):552 scroll_to_bottom(pytest.web_driver)553 now = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['554 '@data-event-content="ÐабиÑинÑ. СейÑаÑ"]')555 now.click()556 pytest.web_driver.implicitly_wait(2)557 assert pytest.web_driver.find_element_by_xpath(558 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐабиÑинÑ. СейÑаÑ"559560 def test_page_bottom_menu_child_now(self):561 scroll_to_bottom(pytest.web_driver)562 child_now = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['563 '@data-event-content="ÐеÑÑкий навигаÑоÑ"]')564 child_now.click()565 pytest.web_driver.implicitly_wait(2)566 assert pytest.web_driver.find_element_by_xpath(567 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐеÑÑкий навигаÑоÑ"568569 def test_page_bottom_menu_reviews(self):570 scroll_to_bottom(pytest.web_driver)571 reviews = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['572 '@data-event-content="РеÑензии ÑиÑаÑелей"]')573 reviews.click()574 pytest.web_driver.implicitly_wait(2)575 assert pytest.web_driver.find_element_by_xpath(576 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "РеÑензии ÑиÑаÑелей"577578 def test_page_bottom_menu_book_reviews(self):579 scroll_to_bottom(pytest.web_driver)580 book_reviews = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['581 '@data-event-content="ÐнижнÑе обзоÑÑ"]')582 book_reviews.click()583 pytest.web_driver.implicitly_wait(2)584 assert pytest.web_driver.find_element_by_xpath(585 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐнижнÑе обзоÑÑ"586587 def test_page_bottom_menu_recommendations(self):588 scroll_to_bottom(pytest.web_driver)589 recommendations = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['590 '@data-event-content="ÐодбоÑки ÑиÑаÑелей"]')591 recommendations.click()592 pytest.web_driver.implicitly_wait(2)593 assert pytest.web_driver.find_element_by_xpath(594 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐодбоÑки ÑиÑаÑелей"595596 def test_page_bottom_menu_tests(self):597 scroll_to_bottom(pytest.web_driver)598 tests = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['599 '@data-event-content="ТеÑÑÑ"]')600 tests.click()601 pytest.web_driver.implicitly_wait(2)602 assert pytest.web_driver.find_element_by_xpath(603 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐиÑÑеÑÑÑ"604605 def test_page_bottom_menu_news(self):606 scroll_to_bottom(pytest.web_driver)607 news = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['608 '@data-event-content="ÐовоÑÑи Ð."]')609 news.click()610 pytest.web_driver.implicitly_wait(2)611 assert pytest.web_driver.find_element_by_xpath(612 '//div[@class="ratingh h1"]').text == "ÐовоÑÑи ÐабиÑинÑа"613614 def test_page_bottom_menu_contests(self):615 scroll_to_bottom(pytest.web_driver)616 contests = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['617 '@data-event-content="ÐонкÑÑÑÑ"]')618 contests.click()619 pytest.web_driver.implicitly_wait(2)620 assert pytest.web_driver.find_element_by_xpath(621 '//a[@class="mm-link mm-link-big mm-link-big-m-sub active"]').text == "ÐонкÑÑÑÑ"622623 def test_page_bottom_menu_club(self):624 scroll_to_bottom(pytest.web_driver)625 club = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['626 '@data-event-content="СпеÑпÑоекÑÑ"]')627 club.click()628 pytest.web_driver.implicitly_wait(2)629 title = pytest.web_driver.title630 assert title == 'ÐнижнÑй клÑб инÑеÑнеÑ-магазина ÐабиÑинÑ'631632633class TestPageBottomMenuLabAll: # check bottom links in menu "ÐабиÑÐ¸Ð½Ñ â вÑем"634 def test_page_bottom_menu_partner(self):635 scroll_to_bottom(pytest.web_driver)636 partner = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['637 '@data-event-content="ÐаÑÑнеÑам"]')638 partner.click()639 pytest.web_driver.implicitly_wait(2)640 title = pytest.web_driver.title641 assert title == "ÐаÑÑнеÑÑÐºÐ°Ñ Ð¿ÑогÑамма ÐабиÑинÑ.ÑÑ"642643 def test_page_bottom_menu_vacancy(self):644 scroll_to_bottom(pytest.web_driver)645 vacancy = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['646 '@data-event-content="ÐаÑи ваканÑии"]')647 vacancy.click()648 time.sleep(2)649 parent = pytest.web_driver.window_handles[0]650 chld = pytest.web_driver.window_handles[1]651 pytest.web_driver.switch_to.window(chld)652 title = pytest.web_driver.title653 assert title == "ÐздаÑелÑÑÑва ÐоÑÐºÐ²Ñ Ð²Ð°ÐºÐ°Ð½Ñии | ÐнигоÑоÑговÑй и издаÑелÑÑкий Ñ
олдинг «ÐабиÑинÑ»"654 pytest.web_driver.close()655 pytest.web_driver.switch_to.window(parent)656657658class TestPageBottomMenuMyLab: # check bottom links in menu "Ðой ÐабиÑинÑ"659 def test_page_bottom_menu_enter_by_code(self):660 scroll_to_bottom(pytest.web_driver)661 enter_by_code = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['662 '@data-event-content="ÐойÑи по ÐºÐ¾Ð´Ñ Ñкидки или ÑеÑез '663 'ÑоÑÑеÑÑ"]')664 enter_by_code.click()665 assert pytest.web_driver.find_element_by_xpath(666 '//div[@class="js-auth__title new-auth__title"]').text == "ÐолнÑй доÑÑÑп к ÐабиÑинÑÑ"667668 def test_page_bottom_menu_enter(self):669 scroll_to_bottom(pytest.web_driver)670 enter = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['671 '@data-event-content="ÐÑ
од и ÑегиÑÑÑаÑиÑ"]')672 enter.click()673 assert pytest.web_driver.find_element_by_xpath(674 '//div[@class="js-auth__title new-auth__title"]').text == "ÐолнÑй доÑÑÑп к ÐабиÑинÑÑ"675676 def test_page_bottom_menu_visited(self):677 scroll_to_bottom(pytest.web_driver)678 visited = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['679 '@data-event-content="ÐÑ ÑмоÑÑели"]')680 visited.click()681 assert pytest.web_driver.find_element_by_xpath(682 '//li[@class="cabinet-menu__tab cabinet-menu__tab_active"]/a/span').text == "ÐÑÑоÑÐ¸Ñ Ð¿ÑоÑмоÑÑа"683684 def test_page_bottom_menu_cabinet(self):685 scroll_to_bottom(pytest.web_driver)686 cabinet = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['687 '@data-event-content="ÐабинеÑ"]')688 cabinet.click()689 assert pytest.web_driver.find_element_by_xpath(690 '//div[@class="js-auth__title new-auth__title"]').text == "ÐолнÑй доÑÑÑп к ÐабиÑинÑÑ"691692693class TestPageBottomMenuHelp: # check bottom links in menu "ÐомоÑÑ"694 def test_page_bottom_menu_order(self):695 scroll_to_bottom(pytest.web_driver)696 order = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['697 '@data-event-content="Ðак ÑделаÑÑ Ð·Ð°ÐºÐ°Ð·"]')698 order.click()699 title = pytest.web_driver.title700 assert title == "Ðаказ Ð´Ð»Ñ ÑÑидиÑеÑкиÑ
Ð»Ð¸Ñ | ÐабиÑинÑ"701702 def test_page_bottom_menu_clauser(self):703 scroll_to_bottom(pytest.web_driver)704 clause = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['705 '@data-event-content="ÐплаÑа"]')706 clause.click()707 title = pytest.web_driver.title708 assert title == "ÐплаÑа | ÐабиÑинÑ"709 clause132_menu = pytest.web_driver.find_element_by_id('helpmenu132')710 clause_style = clause132_menu.get_attribute('style')711 # print(clause_style[-7:-1])712 assert clause_style[-6:-1] == "block"713714 def test_page_bottom_menu_delivery(self):715 scroll_to_bottom(pytest.web_driver)716 delivery = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['717 '@data-event-content="ÐоÑÑавка"]')718 delivery.click()719 title = pytest.web_driver.title720 assert title == "ÐомоÑÑ | ÐабиÑинÑ"721722 def test_page_bottom_menu_support(self):723 scroll_to_bottom(pytest.web_driver)724 support = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['725 '@data-event-content="ÐоддеÑжка"]')726 support.click()727 title = pytest.web_driver.title728 assert title == "СлÑжба поддеÑжки | ÐоддеÑжка лабиÑинÑа"729730 def test_page_bottom_menu_mail_to(self):731 scroll_to_bottom(pytest.web_driver)732 mail_to = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['733 '@data-event-content="ÐапиÑиÑе нам"]')734 link = mail_to.get_attribute('href')735 assert link == 'mailto:shop@labirintmail.ru'736 print('\nSend e-mail to:\t', link[7:])737738 def test_page_bottom_menu_all_support(self):739 scroll_to_bottom(pytest.web_driver)740 all_support = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['741 '@data-event-content="ÐÑÑ Ð¿Ð¾Ð¼Ð¾ÑÑ"]')742 all_support.click()743 title = pytest.web_driver.title744 assert title == "ÐомоÑÑ | ÐабиÑинÑ"745746 def test_page_bottom_menu_agreement(self):747 scroll_to_bottom(pytest.web_driver)748 agreement = pytest.web_driver.find_element_by_xpath('//li[@class="b-rfooter-e-item"]/a['749 '@data-event-content="ÐолÑзоваÑелÑÑкое ÑоглаÑение"]')750 agreement.click()751 title = pytest.web_driver.title752 assert title == "ÐолÑзоваÑелÑÑкое СоглаÑение об ÑÑловиÑÑ
пÑедоÑÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ Ð£ÑлÑг в инÑеÑнеÑ-магазине ÐабиÑÐ¸Ð½Ñ | " \
...
message_buffer.py
Source:message_buffer.py
...38 """Adds a message into the buffer."""39 self.list_box.add(message)40 # Scroll to the bottom if this is our own message.41 if message.sender == self.room.network.nickname:42 self.scroll_to_bottom(self.list_box)43 44 def on_window_scroll(self, widget, data=None):45 """value-changed signal handler for the window adjustment.46 47 This is used to detect when the user scrolls up, so that we can 48 disconnect the `scroll_to_bottom` handler when we get a new message.49 """50 adj = self.get_vadjustment()51 max_value = adj.get_upper() - adj.get_page_size()52 if adj.get_value() < max_value:53 try:54 self.list_box.disconnect_by_func(self.scroll_to_bottom)55 56 except TypeError:57 pass58 59 else:60 try:61 self.list_box.disconnect_by_func(self.scroll_to_bottom)62 63 except TypeError:64 pass65 self.list_box.connect('size-allocate', self.scroll_to_bottom)66 def scroll_to_bottom(self, widget, data=None):67 """Scroll to the bottom of the buffer."""68 adj = self.get_vadjustment()69 max_value = adj.get_upper() - adj.get_page_size()...
executing_javascript.py
Source:executing_javascript.py
1from selenium.common.exceptions import JavascriptException2from webdriver_setup import get_webdriver_for3from time import sleep4driver = get_webdriver_for("firefox")5driver.get("https://www.pythondoctor.com/bopi/")6sleep(1)7# remove header from page8remove_header = """9header = document.getElementsByTagName("header")[0];10header.style.display = "none";11"""12driver.execute_script(remove_header)13sleep(1)14# change the color of background15change_background = "document.body.style.background = '#ccc';"16driver.execute_script(change_background)17sleep(1)18# scroll to bottom of the page19scroll_to_bottom = "window.scrollTo(0, document.body.scrollHeight);"20driver.execute_script(scroll_to_bottom)21sleep(3)22# scrollTo was changed as scrollT to get an exception23try:24 scroll_to_bottom = "window.scrollT(0, document.body.scrollHeight);"25 driver.execute_script(scroll_to_bottom)26except JavascriptException as e:27 print(e)28finally:...
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!!