Best Python code snippet using SeleniumBase
hack_the_planet.py
Source:hack_the_planet.py
...18 yt_chip = "#chips yt-chip-cloud-chip-renderer:nth-of-type"19 wiki = "https://en.wikipedia.org/wiki/All_your_base_are_belong_to_us"20 self.open(wiki)21 self.click_if_visible('button[aria-label="Close"]')22 self.set_text_content("h1#firstHeading", aybabtu)23 self.set_text_content("#ca-history a", aybabtu)24 self.set_text_content('#n-mainpage-description a', "ALL")25 self.set_text_content('#n-contents a', "YOUR")26 self.set_text_content('#n-currentevents a', "BASE")27 self.set_text_content('#n-randompage a', "ARE")28 self.set_text_content('#n-aboutsite a', "BELONG")29 self.set_text_content('#n-contactpage a', "TO")30 self.set_text_content('#n-sitesupport a', "US")31 self.set_text_content('.tocsection-1 span.toctext', "ALL")32 self.set_text_content('.tocsection-2 span.toctext', "YOUR")33 self.set_text_content('.tocsection-3 span.toctext', "BASE")34 self.set_text_content('.tocsection-4 span.toctext', "ARE")35 self.set_text_content('.tocsection-5 span.toctext', "BELONG")36 self.set_text_content('.tocsection-6 span.toctext', "TO")37 self.set_text_content('.tocsection-7 span.toctext', "US")38 self.highlight("h1#firstHeading", loops=2, scroll=False)39 self.highlight("#ca-history a", loops=2, scroll=False)40 self.highlight("nav#p-navigation", loops=2, scroll=False)41 self.highlight("div#toc", loops=2, scroll=False)42 self.highlight('.tocsection-1 span.toctext', loops=1, scroll=False)43 self.highlight('.tocsection-2 span.toctext', loops=1, scroll=False)44 self.highlight('.tocsection-3 span.toctext', loops=2, scroll=False)45 self.highlight('.tocsection-4 span.toctext', loops=1, scroll=False)46 self.highlight('.tocsection-5 span.toctext', loops=1, scroll=False)47 self.highlight('.tocsection-6 span.toctext', loops=1, scroll=False)48 self.highlight('.tocsection-7 span.toctext', loops=2, scroll=False)49 zoom_in = 'div.thumbinner{zoom: 1.4;-moz-transform: scale(1.4);}'50 self.add_css_style(zoom_in)51 self.highlight("div.thumbinner", loops=8, scroll=False)52 self.open("https://www.apple.com/store")53 self.set_text_content("div.rs-shop-subheader", aybabtu)54 self.set_text_content('#shelf-1 a[href*="mac"]', "ALL")55 self.set_text_content('#shelf-1 a[href*="iphone"]', "YOUR")56 self.set_text_content('#shelf-1 a[href*="ipad"]', "BASE")57 self.set_text_content('#shelf-1 a[href*="watch"]', "ARE")58 self.set_text_content('#shelf-1 a[href*="airpods"]', "BELONG")59 self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")60 self.set_text_content('#shelf-1 a[href*="tv"]', "US")61 self.set_text_content('#shelf-1 a[href*="homepod"]', ".")62 self.set_text_content("h2", aybabtu + ". ")63 self.highlight("div.rs-shop-subheader", loops=6, scroll=False)64 self.highlight("#shelf-1", loops=2, scroll=False)65 self.highlight('#shelf-1 a[href*="mac"]', loops=1, scroll=False)66 self.highlight('#shelf-1 a[href*="iphone"]', loops=1, scroll=False)67 self.highlight('#shelf-1 a[href*="ipad"]', loops=3, scroll=False)68 self.highlight('#shelf-1 a[href*="watch"]', loops=1, scroll=False)69 self.highlight('#shelf-1 a[href*="airpods"]', loops=1, scroll=False)70 self.highlight('#shelf-1 a[href*="airtag"]', loops=1, scroll=False)71 self.highlight('#shelf-1 a[href*="tv"]', loops=3, scroll=False)72 self.highlight("h2", loops=9, scroll=False)73 self.open("https://google.com/ncr")74 self.set_text_content('a[href*="about.google"]', ayb)75 self.set_text_content('a[href*="store.google"]', abtu)76 self.set_text_content('a[href*="mail.google.com"]', ayb)77 self.set_text_content('a[href*="google.com/img"]', abtu)78 self.set_attributes('[value="Google Search"]', "value", ayb)79 self.set_attributes('[value="I\'m Feeling Lucky"]', "value", abtu)80 zoom_in = 'a{zoom: 1.2;-moz-transform: scale(1.2);}'81 self.add_css_style(zoom_in)82 zoom_in = (83 '[value="ALL YOUR BASE"]{zoom: 1.3;-moz-transform: scale(1.3);}'84 '[value="ARE BELONG TO US"]{zoom: 1.3;-moz-transform: scale(1.3);}'85 )86 self.add_css_style(zoom_in)87 self.highlight('a[href*="about.google"]', loops=3)88 self.highlight('a[href*="store.google"]', loops=3)89 self.highlight('a[href*="mail.google.com"]', loops=3)90 self.highlight('a[href*="google.com/img"]', loops=3)91 self.highlight('form[role="search"]', loops=8)92 self.open("https://twitter.com/")93 if not self.is_element_visible('a[href*="w/signup"] span'):94 self.refresh()95 if self.is_element_visible('a[href*="w/signup"] span'):96 self.set_text_content('a[href*="w/signup"] span', aybabtu)97 self.highlight('a[href*="w/signup"] span', loops=6, scroll=False)98 self.highlight('a[href*="w/signup"]', loops=6, scroll=False)99 self.open("https://www.youtube.com/")100 self.set_text_content('%s(1)' % yt_chip, "ALL")101 self.set_text_content('%s(2)' % yt_chip, "YOUR")102 self.set_text_content('%s(3)' % yt_chip, "BASE")103 self.set_text_content('%s(4)' % yt_chip, "ARE")104 self.set_text_content('%s(5)' % yt_chip, "BELONG")105 self.set_text_content('%s(6)' % yt_chip, "TO")106 self.set_text_content('%s(7)' % yt_chip, "US")107 self.set_text_content('%s(8)' % yt_chip, "!")108 self.set_text_content('%s(9)' % yt_chip, "!")109 self.set_text_content('%s(10)' % yt_chip, "!")110 self.click_if_visible("#dismiss-button")111 self.click_if_visible('button[aria-label="Close"]')112 self.highlight("#scroll-container", loops=5, scroll=False)113 self.highlight('%s(1)' % yt_chip, loops=1, scroll=False)114 self.highlight('%s(2)' % yt_chip, loops=1, scroll=False)115 self.highlight('%s(3)' % yt_chip, loops=3, scroll=False)116 self.highlight('%s(4)' % yt_chip, loops=1, scroll=False)117 self.highlight('%s(5)' % yt_chip, loops=1, scroll=False)118 self.highlight('%s(6)' % yt_chip, loops=1, scroll=False)119 self.highlight('%s(7)' % yt_chip, loops=3, scroll=False)120 self.highlight("#scroll-container", loops=7, scroll=False)121 self.open("https://github.com/features/actions")122 self.set_text_content('a[href="/team"]', ayb)123 self.set_text_content('a[href="/enterprise"]', abtu)124 self.set_text_content('h1 span:nth-child(1)', ayb)125 self.set_text_content('h1 span:nth-of-type(2)', "ARE")126 self.set_text_content('h1 span:nth-of-type(3)', "BELONG")127 self.set_text_content('h1 span:nth-of-type(4)', "TO")128 self.set_text_content('h1 span:nth-of-type(5)', "US")129 self.type('input[name="q"]', aybabtu.lower())130 self.click("h1", scroll=False)131 self.highlight("nav", loops=5, scroll=False)132 self.highlight('input[name="q"]', loops=5, scroll=False)133 self.highlight("h1", loops=8, scroll=False)134 self.open("https://dev.to/top/infinity")135 self.click_if_visible('button[aria-label="Close campaign banner"]')136 self.set_text_content('nav a[data-text="Relevant"]', "ALL")137 self.set_text_content('nav a[data-text="Latest"]', "YOUR")138 self.set_text_content('nav a[data-text="Top"]', "BASE")139 self.set_text_content('nav a[data-text="Week"]', "ARE")140 self.set_text_content('nav a[data-text="Month"]', "BELONG")141 self.set_text_content('nav a[data-text="Year"]', "TO")142 self.set_text_content('nav a[data-text="Infinity"]', "US")143 self.set_text_content('aside a[class*="tful"]', aybabtu)144 self.set_text_content('aside a[aria-label="Create new account"]', ayb)145 self.set_text_content('aside a[aria-label="Log in"]', abtu)146 self.set_text_content('aside a[class*="tful"]:nth-child(2)', aybabtu)147 self.set_text_content('aside a[class*="tful"]:nth-child(3)', aybabtu)148 self.set_text_content('aside a[class*="tful"]:nth-child(4)', aybabtu)149 self.set_text_content('aside a[class*="tful"]:nth-child(5)', aybabtu)150 self.set_attribute("a.crayons-avatar img", "src", sb_dashboard_logo)151 self.set_text_content('.profile-preview-card button', "SeleniumBase")152 self.set_text_content('h2.crayons-story__title a', aybabtu)153 self.type('input[name="q"]', aybabtu)154 self.highlight('input[name="q"]', loops=4, scroll=False)155 self.highlight('[aria-label="Primary sidebar"] div div', scroll=False)156 self.highlight('nav a[data-text="Relevant"]', loops=1, scroll=False)157 self.highlight('nav a[data-text="Latest"]', loops=1, scroll=False)158 self.highlight('nav a[data-text="Top"]', loops=2, scroll=False)159 self.highlight('nav a[data-text="Week"]', loops=1, scroll=False)160 self.highlight('nav a[data-text="Month"]', loops=1, scroll=False)161 self.highlight('nav a[data-text="Year"]', loops=1, scroll=False)162 self.highlight('nav a[data-text="Infinity"]', loops=2, scroll=False)163 self.highlight('aside[id*="sidebar"] section', loops=5, scroll=False)164 self.highlight("div.crayons-story__body", loops=7, scroll=False)165 self.open("https://azure.microsoft.com/en-us/services/playfab/")166 self.set_text_content("h1", aybabtu)167 self.set_text_content('a[aria-label*="Try PlayF"]', ayb)168 self.set_text_content('a[aria-label*="Sign in to"]', abtu)169 self.set_text_content('span:contains("Chat with Sales")', aybabtu)170 self.highlight("h1", loops=6, scroll=False)171 self.highlight('a[aria-label*="Try PlayF"]', loops=4, scroll=False)172 self.highlight('a[aria-label*="Sign in to"]', loops=4, scroll=False)173 self.highlight('button#live-engage-btn', loops=6, scroll=False)174 self.open("https://www.snapchat.com/")175 self.set_text_content("h1", ayb)176 self.set_text_content("form .button-large span span", abtu)177 zoom_in = 'a.button-large span{zoom: 1.2;-moz-transform: scale(1.2);}'178 self.add_css_style(zoom_in)179 self.highlight("h1", loops=6, scroll=False)180 self.highlight("form .button-large span span", loops=8, scroll=False)181 self.open("https://store.steampowered.com/")182 self.set_text_content('div.content a[href*="/about/"]', " ")183 self.set_text_content('div.content a[href*="help.steam"]', aybabtu)184 self.set_text_content("#foryou_tab a", "ALL")185 self.set_text_content("#noteworthy_tab a", "YOUR BASE")186 self.set_text_content("#genre_tab a", "ARE")187 self.set_text_content('span:contains("Points Shop")', "BELONG")188 self.set_text_content('span:contains("News")', "TO")189 self.set_text_content('span:contains("Labs")', "US")190 self.set_value("input#store_nav_search_term", ayb + " . . . .")191 self.highlight('div.content a[href*="help.steam"]', loops=6)192 self.highlight('#store_nav_area', loops=2, scroll=False)193 self.highlight("#foryou_tab a", loops=1, scroll=False)194 self.highlight("#noteworthy_tab a", loops=3, scroll=False)195 self.highlight("#genre_tab a", loops=1, scroll=False)196 self.highlight('span:contains("BELONG")', loops=1, scroll=False)197 self.highlight('span:contains("TO")', loops=1, scroll=False)198 self.highlight('span:contains("US")', loops=2, scroll=False)199 self.js_click('input[id*="nav_search"]')200 self.highlight('input[id*="nav_search"]', loops=6, scroll=False)201 self.open("https://xkcd.com/286/")202 self.set_text_content('a[href="/archive"]', "ALL")203 self.set_text_content('a[href*="what-if"]', "YOUR")204 self.set_text_content('a[href*="//blag."]', "BASE")205 self.set_text_content('a[href*="/about"]', abtu)206 self.remove_element('li:contains("Feed")')207 self.remove_element('li:contains("TW")')208 self.remove_element('li:contains("Books")')209 self.remove_element('li:contains("What")')210 self.remove_element('li:contains("WI")')211 self.set_attributes("#news img", "src", sb_banner_logo)212 self.set_text_content('#ctitle', aybabtu)213 self.set_text_content('a[rel="prev"]', "All")214 self.set_text_content('a[href*="random"]', "Your")215 self.set_text_content('a[rel="next"]', "Base")216 self.highlight("#topLeft ul", loops=5, scroll=False)217 self.highlight('a[href="/archive"]', loops=1, scroll=False)218 self.highlight('a[href*="what-if"]', loops=1, scroll=False)219 self.highlight('a[href*="//blag."]', loops=2, scroll=False)220 self.highlight('a[href*="/about"]', loops=5, scroll=False)221 self.highlight('a[rel="prev"]', loops=1, scroll=False)222 self.highlight('a[href*="random"]', loops=1, scroll=False)223 self.highlight('a[rel="next"]', loops=3, scroll=False)224 self.highlight("#ctitle", loops=7, scroll=False)225 self.open("https://www.nintendo.com/whatsnew/")226 self.set_text_content('button[aria-label="Search"]', aybabtu)227 self.set_text_content('button[data-section="newsevents"]', aybabtu)228 self.set_text_content("h2", aybabtu)229 self.highlight('div.search-flex', loops=4, scroll=False)230 self.highlight('button[data-section*="news"]', loops=4, scroll=False)231 self.highlight("h2", loops=6, scroll=False)232 self.open("https://support.gog.com/hc/en-us?product=gog")233 self.set_text_content("div.intro-title", aybabtu)234 self.set_text_content("h4", aybabtu)235 self.highlight("div.intro-title", loops=8, scroll=False)236 self.highlight("h4", loops=8, scroll=False)237 self.open("https://slack.com/help/articles/204714258-Giphy-for-Slack")238 self.set_text_content("h1", aybabtu)239 self.set_text_content('a[prettyslug="getting-started"]', "ALL")240 self.set_text_content('a[prettyslug="using-slack"]', "YOUR")241 self.set_text_content('a[prettyslug="your-profile"]', "BASE")242 self.set_text_content('a[prettyslug="connect-tools"]', "ARE")243 self.set_text_content('a[prettyslug="administration"]', "BELONG")244 self.set_text_content('a[prettyslug="tutorials"]', "TO US")245 self.highlight("h1", loops=4, scroll=False)246 self.highlight("div#global_menu", loops=2, scroll=False)247 self.highlight('a[prettyslug*="g-started"]', loops=1, scroll=False)248 self.highlight('a[prettyslug="using-slack"]', loops=1, scroll=False)249 self.highlight('a[prettyslug="your-profile"]', loops=2, scroll=False)250 self.highlight('a[prettyslug="connect-tools"]', loops=1, scroll=False)251 self.highlight('a[prettyslug="administration"]', loops=1, scroll=False)252 self.highlight('a[prettyslug="tutorials"]', loops=2, scroll=False)253 self.open("https://kubernetes.io/")254 self.set_text_content('nav a[href="/docs/"]', "ALL")255 self.set_text_content('nav a[href="/blog/"]', "YOUR")256 self.set_text_content('nav a[href="/training/"]', "BASE")257 self.set_text_content('nav a[href="/partners/"]', "ARE")258 self.set_text_content('nav a[href="/community/"]', "BELONG")259 self.set_text_content('nav a[href="/case-studies/"]', "TO")260 self.set_text_content('nav #navbarDropdown', "US")261 self.set_text_content('nav #navbarDropdownMenuLink', ".")262 if self.is_element_visible("h1"):263 self.set_text_content("h1", aybabtu)264 self.highlight("nav ul.navbar-nav", loops=3, scroll=False)265 self.highlight('nav a[href="/docs/"]', loops=1, scroll=False)266 self.highlight('nav a[href="/blog/"]', loops=1, scroll=False)267 self.highlight('nav a[href="/training/"]', loops=2, scroll=False)268 self.highlight('nav a[href="/partners/"]', loops=1, scroll=False)269 self.highlight('nav a[href="/community/"]', loops=1, scroll=False)270 self.highlight('nav a[href="/case-studies/"]', loops=1, scroll=False)271 self.highlight('nav #navbarDropdown', loops=2, scroll=False)272 if self.is_element_visible("h1"):273 self.highlight('h1', loops=6, scroll=False)274 self.open("https://www.selenium.dev/")275 self.set_attributes("a.dropdown-toggle", "class", "nav-link")276 self.set_text_content('li a:contains("About")', "ALL")277 self.set_text_content('li a:contains("Downloads")', "YOUR")278 self.set_text_content('li a:contains("Documentation")', "BASE")279 self.set_text_content('li a:contains("Projects")', "ARE")280 self.set_text_content('li a:contains("Support")', "BELONG")281 self.set_text_content('li a:contains("Blog")', "TO")282 self.set_text_content('li a:contains("English")', "US")283 self.set_text_content("div.lead", aybabtu)284 self.set_text_content("h2", aybabtu)285 zoom_in = 'div.lead{zoom: 1.25;-moz-transform: scale(1.25);}'286 self.add_css_style(zoom_in)287 self.highlight("div#main_navbar", loops=1, scroll=False)288 self.highlight('li a:contains("ALL")', loops=1, scroll=False)289 self.highlight('li a:contains("YOUR")', loops=1, scroll=False)290 self.highlight('li a:contains("BASE")', loops=2, scroll=False)291 self.highlight('li a:contains("ARE")', loops=1, scroll=False)292 self.highlight('li a:contains("BELONG")', loops=1, scroll=False)293 self.highlight('li a:contains("TO")', loops=1, scroll=False)294 self.highlight('li a:contains("US")', loops=2, scroll=False)295 self.highlight("div.lead", loops=6, scroll=False)296 self.highlight("h2", loops=8, scroll=False)297 self.open("https://www.python.org/")298 self.set_text_content('a[class="donate-button"]', ayb)299 self.set_text_content("#about a", "ALL")300 self.set_text_content("#downloads a", "YOUR")301 self.set_text_content("#documentation a", "BASE")302 self.set_text_content("#community a", "ARE")303 self.set_text_content("#success-stories a", "BELONG")304 self.set_text_content("#news a", "TO")305 self.set_text_content("#events a", "US")306 self.highlight('a[class="donate-button"]', loops=4, scroll=False)307 self.highlight("nav#mainnav", loops=5, scroll=False)308 self.highlight("#about a", loops=1, scroll=False)309 self.highlight("#downloads a", loops=1, scroll=False)310 self.highlight("#documentation a", loops=2, scroll=False)311 self.highlight("#community a", loops=1, scroll=False)312 self.highlight("#success-stories a", loops=1, scroll=False)313 self.highlight("#news a", loops=1, scroll=False)314 self.highlight("#events a", loops=2, scroll=False)315 self.open("https://docs.pytest.org/")316 self.set_text_content("h1", "pytest: " + aybabtu)317 self.highlight("h1", loops=10, scroll=False)318 self.open("https://wordpress.com/")319 self.set_text_content('a[title="Plans & Pricing"]', aybabtu)320 self.set_text_content('a[title="Get Started"]', ayb)321 self.set_text_content("p.no-widows", aybabtu)322 self.set_text_content("a#lpc-button", "Automate with SeleniumBase")323 self.highlight('a[title="Plans & Pricing"]', loops=6, scroll=False)324 self.highlight('a[title="Get Started"]', loops=4, scroll=False)325 self.highlight("p.no-widows", loops=8, scroll=False)326 self.highlight("a#lpc-button", loops=4, scroll=False)327 self.open("https://seleniumbase.com/")328 self.set_text_content("h1", aybabtu)329 self.highlight("h1", loops=10, scroll=False)330 self.open("https://pypi.org/")331 self.set_text_content('a[href="/sponsors/"]', aybabtu)332 self.set_text_content("h1", aybabtu)333 self.set_value("input#search", aybabtu, scroll=False)334 self.highlight('a[href="/sponsors/"]', loops=6, scroll=False)335 self.highlight("h1", loops=6, scroll=False)336 self.highlight("input#search", loops=8, scroll=False)337 self.open("https://www.atlassian.com/software/jira")338 self.set_text_content('a[href*="jira/pricing"]', ayb)339 self.set_text_content('a[href*="jira/enterprise"]', abtu)340 self.set_text_content('a[href="/software/jira/features"]', "")341 self.set_text_content('a[href="/software/jira/guides"]', "")342 self.set_text_content("h1", ayb)343 self.set_text_content('div.xs-none-bottom a[href*="free"]', abtu)344 self.highlight("ul.imkt-navbar__link-list", loops=2, scroll=False)345 self.highlight('a[href*="jira/pricing"]', loops=3, scroll=False)346 self.highlight('a[href*="jira/enterprise"]', loops=3, scroll=False)347 self.highlight("h1", loops=3, scroll=False)348 self.highlight('div.xs-none-bottom a[href*="free"]', scroll=False)349 self.open("https://status.iboss.com/ibcloud/app/cloudStatus.html")350 self.set_text_content('div[translate*="cloudStatus"]', ayb)351 self.set_text_content('div[translate*="maintenance"]', "ARE")352 self.set_text_content('div[translate*="advisory"]', "BELONG")353 self.set_text_content('div[translate*="incident"]', "TO US")354 self.set_text_content("h1", "Cloud Status - " + aybabtu)355 self.highlight("nav div.ibcloud-header-contents", loops=3)356 self.highlight('div[translate*="cloudStatus"]', loops=4)357 self.highlight('div[translate*="maintenance"]', loops=1)358 self.highlight('div[translate*="advisory"]', loops=1)359 self.highlight('div[translate*="incident"]', loops=3)360 self.highlight("h1", loops=9, scroll=False)361 self.open("https://git-scm.com/")362 self.set_text_content("span#tagline", aybabtu)363 self.set_text_content("#nav-about h3", ayb)364 self.set_text_content("#nav-documentation h3", abtu)365 self.highlight("span#tagline", loops=8, scroll=False)366 self.highlight("#nav-about h3", loops=5, scroll=False)367 self.highlight("#nav-documentation h3", loops=6, scroll=False)368 self.open("https://teamtreehouse.com/")369 self.set_text_content("li.nav-item-free-trial", aybabtu)370 self.set_text_content("h1", aybabtu)371 self.set_text_content("h2", aybabtu)372 self.set_text_content("p.homepage-signup-form-banner", aybabtu)373 self.highlight("li.nav-item-free-trial", loops=6, scroll=False)374 self.highlight("h1", loops=6, scroll=False)375 self.highlight('p[class*="signup-form"]', loops=8, scroll=False)376 self.open("https://pragprog.com/")377 self.set_text_content("header p", aybabtu)378 zoom_in = 'header p{zoom: 1.35;-moz-transform: scale(1.35);}'379 self.add_css_style(zoom_in)380 self.highlight("header p", loops=10, scroll=False)381 self.open("https://seleniumbase.io/")382 self.set_text_content("h1", aybabtu)...
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!!