@@ -352,10 +352,10 @@ def test_presentation_4(self):
352352 )
353353 self .begin_presentation (filename = "uc_presentation.html" )
354354
355- with SB (uc = True , test = True ) as sb :
356- url = "www.planetminecraft.com/account/sign_in/"
357- sb .activate_cdp_mode ( url )
358- sb .sleep (2 )
355+ with SB (uc = True , test = True , guest = True ) as sb :
356+ sb . activate_cdp_mode ()
357+ sb .goto ( "www.planetminecraft.com/account/sign_in/" )
358+ sb .sleep (3 )
359359 sb .solve_captcha ()
360360 sb .wait_for_element_absent ("input[disabled]" )
361361 sb .sleep (2 )
@@ -384,16 +384,16 @@ def test_presentation_4(self):
384384 self .begin_presentation (filename = "uc_presentation.html" )
385385
386386 with SB (uc = True , test = True , locale = "en" ) as sb :
387- url = "https://gitlab.com/users/sign_in"
388- sb .activate_cdp_mode ( url )
387+ sb . activate_cdp_mode ()
388+ sb .goto ( "https://gitlab.com/users/sign_in" )
389389 sb .sleep (2 )
390390 sb .solve_captcha ()
391391 # (The rest is for testing and demo purposes)
392- sb .assert_text ("Username" , '[for="user_login"]' , timeout = 3 )
393392 sb .assert_element ('label[for="user_login"]' )
394- sb .highlight ('button:contains("Sign in")' )
395- sb .highlight ('h1:contains("GitLab")' )
396- sb .post_message ("SeleniumBase wasn't detected" , duration = 4 )
393+ sb .assert_element ('input[data-testid*="username"]' )
394+ sb .assert_element ('input[data-testid*="password"]' )
395+ sb .set_messenger_theme (location = "bottom_center" )
396+ sb .post_message ("SeleniumBase wasn't detected!" )
397397
398398 self .create_presentation (theme = "serif" , transition = "none" )
399399 self .add_slide (
@@ -436,9 +436,9 @@ def test_presentation_4(self):
436436 self .begin_presentation (filename = "uc_presentation.html" )
437437
438438 with SB (uc = True , test = True ) as sb :
439- url = "https://www.bing.com/turing/captcha/challenge"
440- sb .activate_cdp_mode ( url )
441- sb .sleep (1 )
439+ sb . activate_cdp_mode ()
440+ sb .goto ( "https://www.bing.com/turing/captcha/challenge" )
441+ sb .sleep (2 )
442442 sb .solve_captcha ()
443443 sb .sleep (2 )
444444
@@ -461,8 +461,8 @@ def test_presentation_4(self):
461461 self .begin_presentation (filename = "uc_presentation.html" )
462462
463463 with SB (uc = True , test = True , locale = "en" , ad_block = True ) as sb :
464- url = "https://www.pokemon.com/us"
465- sb .activate_cdp_mode ( url )
464+ sb . activate_cdp_mode ()
465+ sb .goto ( "https://www.pokemon.com/us" )
466466 sb .sleep (1.5 )
467467 sb .click_if_visible ("button#onetrust-accept-btn-handler" )
468468 sb .sleep (1.2 )
@@ -511,9 +511,9 @@ def test_presentation_4(self):
511511 self .begin_presentation (filename = "uc_presentation.html" )
512512
513513 with SB (uc = True , test = True , ad_block = True ) as sb :
514- url = "https://www.walmart.com/"
515- sb .activate_cdp_mode ( url )
516- sb .sleep (1.8 )
514+ sb . activate_cdp_mode ()
515+ sb .goto ( "https://www.walmart.com/" )
516+ sb .sleep (2.2 )
517517 continue_button = 'button:contains("Continue shopping")'
518518 if sb .is_element_visible (continue_button ):
519519 sb .gui_click_element (continue_button )
@@ -524,12 +524,6 @@ def test_presentation_4(self):
524524 required_text = "Catan"
525525 sb .press_keys ('input[aria-label="Search"]' , search + "\n " )
526526 sb .sleep (3.8 )
527- if sb .is_element_visible ("#px-captcha" ):
528- sb .gui_click_and_hold ("#px-captcha" , 7.2 )
529- sb .sleep (3.2 )
530- if sb .is_element_visible ("#px-captcha" ):
531- sb .gui_click_and_hold ("#px-captcha" , 4.2 )
532- sb .sleep (3.2 )
533527 sb .remove_elements ('[data-testid="skyline-ad"]' )
534528 sb .remove_elements ('[data-testid="sba-container"]' )
535529 print ('*** Walmart Search for "%s":' % search )
@@ -553,12 +547,13 @@ def test_presentation_4(self):
553547 )
554548 if price :
555549 price_text = price .text
556- price_text = (
557- price_text . split ( "current price Now " )[ - 1 ]
558- )
550+ price_text = price_text . split (
551+ "current price Now "
552+ )[ - 1 ]
559553 price_text = price_text .split ("current price " )[- 1 ]
560554 price_text = price_text .split (" " )[0 ]
561555 print (" (" + price_text + ")" )
556+ item .scroll_into_view ()
562557
563558 self .create_presentation (theme = "serif" , transition = "none" )
564559 self .add_slide (
@@ -571,8 +566,8 @@ def test_presentation_4(self):
571566 self .begin_presentation (filename = "uc_presentation.html" )
572567
573568 with SB (uc = True , test = True , locale = "en" ) as sb :
574- url = "https://www.albertsons.com/recipes/"
575- sb .activate_cdp_mode ( url )
569+ sb . activate_cdp_mode ()
570+ sb .goto ( "https://www.albertsons.com/recipes/" )
576571 sb .sleep (2.5 )
577572 sb .remove_element ("div > div > article" )
578573 sb .scroll_into_view ('input[type="search"]' )
@@ -613,9 +608,9 @@ def test_presentation_4(self):
613608 self .begin_presentation (filename = "uc_presentation.html" )
614609
615610 with SB (uc = True , test = True , locale = "en" , ad_block = True ) as sb :
616- url = "https://www.easyjet.com/en/"
617- sb .activate_cdp_mode ( url )
618- sb .sleep (1.5 )
611+ sb . activate_cdp_mode ()
612+ sb .goto ( "https://www.easyjet.com/en/" )
613+ sb .sleep (1.8 )
619614 sb .click_if_visible ("button#ensRejectAds" , timeout = 2 )
620615 sb .sleep (1 )
621616 sb .click ('input[name="from"]' )
@@ -675,8 +670,9 @@ def test_presentation_4(self):
675670
676671 with SB (uc = True , test = True , locale = "en" , ad_block = True ) as sb :
677672 url = "https://www.hyatt.com/"
678- sb .activate_cdp_mode (url )
679- sb .sleep (3.2 )
673+ sb .activate_cdp_mode ()
674+ sb .goto ("https://www.hyatt.com/" )
675+ sb .sleep (3.6 )
680676 sb .click_if_visible ('button[aria-label="Close"]' )
681677 sb .sleep (0.1 )
682678 sb .click_if_visible ("#onetrust-reject-all-handler" )
@@ -685,9 +681,13 @@ def test_presentation_4(self):
685681 sb .type ('input[id="search-term"]' , location )
686682 sb .sleep (1.2 )
687683 sb .click ('li[data-js="suggestion"]' )
688- sb .sleep (1.2 )
684+ sb .sleep (0.6 )
685+ sb .click_if_visible ('button[aria-label="Close"]' )
686+ sb .sleep (0.8 )
689687 sb .click ("button.be-button-shop" )
690- sb .sleep (6 )
688+ sb .sleep (1 )
689+ sb .click_if_visible ('[label="Find Hotels"]' )
690+ sb .sleep (5.5 )
691691 card_info = (
692692 'div[data-booking-status="BOOKABLE"] [class*="HotelCard_info"]'
693693 )
@@ -720,8 +720,8 @@ def test_presentation_4(self):
720720 self .begin_presentation (filename = "uc_presentation.html" )
721721
722722 with SB (uc = True , test = True , locale = "en" , guest = True ) as sb :
723- url = "https://www.bestwestern.com/en_US.html"
724- sb .activate_cdp_mode ( url )
723+ sb . activate_cdp_mode ()
724+ sb .goto ( "https://www.bestwestern.com/en_US.html" )
725725 sb .sleep (3 )
726726 sb .click_if_visible (".onetrust-close-btn-handler" )
727727 sb .sleep (1 )
@@ -762,27 +762,32 @@ def test_presentation_4(self):
762762 self .begin_presentation (filename = "uc_presentation.html" )
763763
764764 with SB (uc = True , test = True , locale = "en" , guest = True , pls = "none" ) as sb :
765- url = "https://www.priceline.com"
766- sb .activate_cdp_mode ( url )
767- sb .sleep (2.6 )
768- input_selector = '[name="endLocation"]'
765+ sb . activate_cdp_mode ()
766+ sb .goto ( "https://www.priceline.com" )
767+ sb .sleep (3 )
768+ input_selector = 'input [name="endLocation"]'
769769 if not sb .is_element_present (input_selector ):
770770 input_selector = "div.location-input input"
771- sb .click (input_selector )
772- sb .sleep (1.2 )
771+ sb .mouse_click (input_selector )
772+ sb .sleep (0.5 )
773773 location = "Portland, OR"
774774 selection = "Oregon, United States" # (Dropdown option)
775775 sb .press_keys (input_selector , location )
776- sb .sleep (0.6 )
776+ sb .sleep (0.5 )
777777 sb .click (selection )
778778 sb .sleep (0.4 )
779779 sb .scroll_down (25 )
780- sb .sleep (0.4 )
780+ sb .sleep (0.2 )
781+ overlay_close = '[aria-label*="Overlay"] [title="Close"]'
781782 calendar_close = 'button[aria-label="Dismiss calendar"]'
782783 if not sb .is_element_visible (calendar_close ):
783784 calendar_close = '[data-mode="range"] span.px-1'
785+ sb .click_if_visible (overlay_close )
786+ sb .sleep (0.3 )
784787 sb .click (calendar_close )
785- sb .sleep (0.6 )
788+ sb .sleep (0.3 )
789+ sb .click_if_visible (overlay_close )
790+ sb .sleep (0.3 )
786791 sb .click ('form button[type="submit"]' )
787792 sb .sleep (4.8 )
788793 if len (sb .get_tabs ()) > 1 :
@@ -793,33 +798,20 @@ def test_presentation_4(self):
793798 for y in range (1 , 9 ):
794799 sb .scroll_to_y (y * 200 )
795800 sb .sleep (0.4 )
796- hotel_names = sb .find_elements ('h3 div[class*="TitleName"]' )
797- if not hotel_names :
798- hotel_names = sb .find_elements ("h3.antialiased" )
799- price_selector = '[class*="PriceWrap"] .relative > .items-center'
800- if sb .is_element_visible (price_selector ):
801- hotel_prices = sb .find_elements (price_selector )
802- elif sb .is_element_present (
803- '[font-size="12px"] + [font-size="20px"]'
804- ):
805- hotel_prices = sb .find_elements (
806- '[font-size="12px"] + [font-size="20px"]'
807- )
808- else :
809- hotel_prices = sb .find_elements (
810- 'span.text-priceSuper-heading4 + div > span'
811- )
812- print ("Priceline Hotels in %s:" % location )
813- if len (hotel_names ) == 0 :
814- print ("No availability over the selected dates!" )
801+ hotels = sb .find_elements ('div[data-vis-key*="content"]' )
815802 count = 0
816- for i , hotel in enumerate (hotel_names ):
817- if hotel_prices [i ] and hotel_prices [i ].text :
818- count += 1
819- hotel_price = "$" + hotel_prices [i ].text
820- if hotel_price .startswith ("$$ " ):
821- hotel_price = hotel_price .replace ("$$ " , "$" )
822- print ("* %s: %s => %s" % (count , hotel .text , hotel_price ))
803+ for hotel in hotels :
804+ title = hotel .query_selector ("h3" )
805+ if title :
806+ price = hotel .query_selector (".text-heading4" )
807+ if price :
808+ count += 1
809+ price_text = price .text .replace (" " , "" )
810+ print (
811+ "* %s: %s => %s" % (count , title .text , price_text )
812+ )
813+ if not count :
814+ print ("No availability over the selected dates!" )
823815
824816 self .create_presentation (theme = "serif" , transition = "none" )
825817 self .add_slide (
@@ -848,8 +840,8 @@ def test_presentation_4(self):
848840 self .begin_presentation (filename = "uc_presentation.html" )
849841
850842 with SB (uc = True , test = True , locale = "en" , pls = "none" ) as sb :
851- url = "https://www.nike.com/"
852- sb .activate_cdp_mode ( url )
843+ sb . activate_cdp_mode ()
844+ sb .goto ( "https://www.nike.com/" )
853845 sb .sleep (2.5 )
854846 sb .click ('[data-testid="user-tools-container"] search' )
855847 sb .sleep (1.5 )
@@ -875,8 +867,8 @@ def test_presentation_4(self):
875867 self .begin_presentation (filename = "uc_presentation.html" )
876868
877869 with SB (uc = True , test = True , locale = "en" ) as sb :
878- url = "https://www.nordstrom.com/"
879- sb .activate_cdp_mode ( url )
870+ sb . activate_cdp_mode ()
871+ sb .goto ( "https://www.nordstrom.com/" )
880872 sb .sleep (2.2 )
881873 sb .click ("input#keyword-search-input" )
882874 sb .sleep (0.8 )
0 commit comments