-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathhack_the_planet.py
342 lines (318 loc) · 19.2 KB
/
hack_the_planet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
""" Video Link: https://youtu.be/1s-Tj65AKZA """
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class HackTests(BaseCase):
def test_all_your_base_are_belong_to_us(self):
self.set_window_size(1250, 740)
ayb = "ALL YOUR BASE"
abtu = "ARE BELONG TO US"
aybabtu = "%s %s" % (ayb, abtu)
sb_banner_logo = "//seleniumbase.github.io/cdn/img/sb_logo_10.png"
sb_dashboard_logo = "//seleniumbase.github.io/img/dash_pie_3.png"
wiki = "https://en.wikipedia.org/wiki/All_your_base_are_belong_to_us"
self.open(wiki)
self.click_if_visible('button[aria-label="Close"]')
self.set_text_content("h1#firstHeading", aybabtu)
self.set_text_content("#ca-history a", aybabtu)
self.set_text_content("#n-mainpage-description a", "ALL")
self.set_text_content("#n-contents a", "YOUR")
self.set_text_content("#n-currentevents a", "BASE")
self.set_text_content("#n-randompage a", "ARE")
self.set_text_content("#n-aboutsite a", "BELONG")
self.set_text_content("#n-contactpage a", "TO US")
self.highlight("h1#firstHeading", loops=5, scroll=False)
zoom_in = "#ca-history a{zoom: 1.8;-moz-transform: scale(1.8);}"
self.add_css_style(zoom_in)
self.highlight("#ca-history a", loops=5, scroll=False)
zoom_in = "img[src*=Ayb]{zoom: 1.6;-moz-transform: scale(1.6);}"
self.add_css_style(zoom_in)
self.highlight("img[src*=Ayb]", loops=10, scroll=False)
if not self.headless:
self.open("https://www.apple.com/store")
self.set_text_content("div.rs-shop-subheader", aybabtu)
self.set_text_content('#shelf-1 a[href*="mac"]', "ALL")
self.set_text_content('#shelf-1 a[href*="iphone"]', "YOUR")
self.set_text_content('#shelf-1 a[href*="ipad"]', "BASE")
self.remove_element('#shelf-1 [role="listitem"]:nth-child(5)')
self.set_text_content('#shelf-1 a[href*="watch"]', "ARE")
self.set_text_content('#shelf-1 a[href*="airpods"]', "BELONG")
self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")
self.set_text_content('#shelf-1 a[href*="tv"]', "US")
self.set_text_content('#shelf-1 a[href*="homepod"]', ".")
self.set_text_content("#shelf-2_section h2", ayb + ". ")
self.set_text_content("#shelf-2_section span", abtu + ". ")
self.highlight("div.rs-shop-subheader", loops=6, scroll=False)
self.highlight("#shelf-1", loops=2, scroll=False)
self.highlight('#shelf-1 a[href*="mac"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="iphone"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="ipad"]', loops=3, scroll=False)
self.highlight('#shelf-1 a[href*="watch"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="airpod"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="airtag"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="tv"]', loops=3, scroll=False)
self.highlight("#shelf-2_section h2", loops=5, scroll=False)
self.highlight("#shelf-2_section span", loops=6, scroll=False)
self.open("https://google.com/ncr")
self.hide_elements("iframe")
if self.is_element_visible('a[href*="about.google"]'):
self.set_text_content('a[href*="about.google"]', ayb)
if self.is_element_visible('a[href*="store.google"]'):
self.set_text_content('a[href*="store.google"]', abtu)
self.set_text_content('a[href*="mail.google.com"]', ayb)
self.set_text_content('a[href*="google.com/img"]', abtu)
self.set_attributes('[value="Google Search"]', "value", ayb)
self.set_attributes('[value="I\'m Feeling Lucky"]', "value", abtu)
self.hide_elements("iframe")
zoom_in = "a{zoom: 1.2;-moz-transform: scale(1.2);}"
self.add_css_style(zoom_in)
zoom_in = (
'[value="ALL YOUR BASE"]{zoom: 1.3;-moz-transform: scale(1.3);}'
'[value="ARE BELONG TO US"]{zoom: 1.3;-moz-transform: scale(1.3);}'
)
self.add_css_style(zoom_in)
self.hide_elements("iframe")
if self.is_element_visible('a[href*="about.google"]'):
self.highlight('a[href*="about.google"]', loops=3)
if self.is_element_visible('a[href*="store.google"]'):
self.highlight('a[href*="store.google"]', loops=3)
self.highlight('a[href*="mail.google.com"]', loops=3)
self.highlight('a[href*="google.com/img"]', loops=3)
self.highlight('form[role="search"]', loops=8)
self.open("https://github.com/features/actions")
self.set_text_content("#hero-section-brand-heading", aybabtu)
self.highlight("#hero-section-brand-heading", loops=14, scroll=False)
self.open("https://dev.to/top/infinity")
self.click_if_visible('button[aria-label="Close campaign banner"]')
self.click_if_visible('svg[aria-label="Close campaign banner"]')
try:
self.hide_elements('main div:contains("Pinned")')
except Exception:
pass
self.set_text_content('nav a[data-text="Relevant"]', "ALL")
self.set_text_content('nav a[data-text="Latest"]', "YOUR")
self.set_text_content('nav a[data-text="Top"]', "BASE")
self.set_text_content('nav a[data-text="Week"]', "ARE")
self.set_text_content('nav a[data-text="Month"]', "BELONG")
self.set_text_content('nav a[data-text="Year"]', "TO")
self.set_text_content('nav a[data-text="Infinity"]', "US")
self.click_if_visible('button[id*="sponsorship-close-trigger"]')
self.set_text_content('aside a[class*="tful"]', aybabtu)
self.set_text_content('aside a[aria-label="Create new account"]', ayb)
self.set_text_content('aside a[aria-label="Log in"]', abtu)
self.set_text_content('aside a[class*="tful"]:nth-child(2)', aybabtu)
self.set_text_content('aside a[class*="tful"]:nth-child(3)', aybabtu)
self.set_text_content('aside a[class*="tful"]:nth-child(4)', aybabtu)
self.set_text_content('aside a[class*="tful"]:nth-child(5)', aybabtu)
self.set_attribute("a.crayons-avatar img", "src", sb_dashboard_logo)
self.set_text_content(".profile-preview-card button", "SeleniumBase")
if self.is_element_visible('h2 a[href*="simonh"]'):
self.set_text_content('h2 a[href*="simonh"]', aybabtu)
if self.is_element_visible('main h2 a[id*="article"]'):
self.set_text_content('main h2 a[id*="article"]', aybabtu)
self.highlight('[aria-label="Primary sidebar"] div div', scroll=False)
self.highlight('nav a[data-text="Relevant"]', loops=1, scroll=False)
self.highlight('nav a[data-text="Latest"]', loops=1, scroll=False)
self.highlight('nav a[data-text="Top"]', loops=2, scroll=False)
self.highlight('nav a[data-text="Week"]', loops=1, scroll=False)
self.highlight('nav a[data-text="Month"]', loops=1, scroll=False)
self.highlight('nav a[data-text="Year"]', loops=1, scroll=False)
self.highlight('nav a[data-text="Infinity"]', loops=3, scroll=False)
if self.is_element_visible('h2 a[href*="simonh"]'):
self.highlight('h2 a[href*="simonh"]', loops=7, scroll=False)
if self.is_element_visible('main h2 a[id*="article"]'):
self.highlight('main h2 a[id*="article"]', loops=7, scroll=False)
self.highlight("section.crayons-card", loops=7, scroll=False)
self.open("https://azure.microsoft.com/en-us/services/playfab/")
self.set_text_content("h1", aybabtu)
self.set_text_content('a[aria-label*="Try Azure"]', ayb)
self.set_text_content('a[aria-label*="Sign in to"]', abtu)
self.remove_elements('div[role="dialog"]')
self.remove_elements('[aria-label*="Microsoft Survey"]')
self.highlight("h1", loops=6, scroll=False)
self.highlight('a[aria-label*="Try Azure"]', loops=4, scroll=False)
self.highlight('a[aria-label*="Sign in to"]', loops=6, scroll=False)
self.open("https://store.steampowered.com/")
self.set_text_content('div.content a[href*="/about/"]', " ")
self.set_text_content('div.content a[href*="help.steam"]', aybabtu)
self.set_text_content("#foryou_tab a", "ALL")
self.set_text_content("#noteworthy_tab a", "YOUR BASE")
self.set_text_content("#genre_tab a", "ARE")
self.set_text_content('span:contains("Points Shop")', "BELONG")
self.set_text_content('span:contains("News")', "TO")
self.set_text_content('span:contains("Labs")', "US")
self.set_value("input#store_nav_search_term", ayb + " . . . .")
self.highlight('div.content a[href*="help.steam"]', loops=6)
self.highlight("#store_nav_area", loops=2, scroll=False)
self.highlight("#foryou_tab a", loops=1, scroll=False)
self.highlight("#noteworthy_tab a", loops=3, scroll=False)
self.highlight("#genre_tab a", loops=1, scroll=False)
self.highlight('span:contains("BELONG")', loops=1, scroll=False)
self.highlight('span:contains("TO")', loops=1, scroll=False)
self.highlight('span:contains("US")', loops=2, scroll=False)
self.js_click('input[id*="nav_search"]')
self.highlight('input[id*="nav_search"]', loops=6, scroll=False)
self.open("https://xkcd.com/286/")
self.set_text_content('a[href="/archive"]', "ALL")
self.set_text_content('a[href*="what-if"]', "YOUR BASE")
self.set_text_content('a[href*="/about"]', abtu)
self.remove_element('li:contains("Feed")')
self.remove_element('li:contains("TW")')
self.remove_element('li:contains("Books")')
self.remove_element('li:contains("What")')
self.remove_element('li:contains("WI")')
self.set_attributes("#countdown img", "src", sb_banner_logo)
self.set_text_content("#ctitle", aybabtu)
self.set_text_content('a[rel="prev"]', "All")
self.set_text_content('a[href*="random"]', "Your")
self.set_text_content('a[rel="next"]', "Base")
self.highlight("#topLeft ul", loops=5, scroll=False)
self.highlight('a[href="/archive"]', loops=1, scroll=False)
self.highlight('a[href*="what-if"]', loops=3, scroll=False)
self.highlight('a[href*="/about"]', loops=5, scroll=False)
self.highlight('a[rel="prev"]', loops=1, scroll=False)
self.highlight('a[href*="random"]', loops=1, scroll=False)
self.highlight('a[rel="next"]', loops=3, scroll=False)
self.highlight("#ctitle", loops=7, scroll=False)
self.open("https://www.nintendo.com/whatsnew/")
self.set_text_content("main section h1", aybabtu)
self.highlight("main section h1", loops=10, scroll=False)
if not self.headless:
self.open("https://support.gog.com/hc/en-us?product=gog")
self.set_text_content("div.intro-title", aybabtu)
self.set_text_content("h4", aybabtu)
self.highlight("div.intro-title", loops=8, scroll=False)
self.highlight("h4", loops=8, scroll=False)
self.open("https://slack.com/help/articles/204714258-Giphy-for-Slack")
self.set_text_content("h1", aybabtu)
self.set_text_content('a[prettyslug="getting-started"]', "ALL")
self.set_text_content('a[prettyslug="using-slack"]', "YOUR")
self.set_text_content('a[prettyslug="your-profile"]', "BASE")
self.set_text_content('a[prettyslug="connect-tools"]', "ARE")
self.set_text_content('a[prettyslug="administration"]', "BELONG")
self.set_text_content('a[prettyslug*="tutorials"]', "TO US")
self.set_text_content("h1.article_title", aybabtu)
self.highlight("h1", loops=4, scroll=False)
self.highlight("div#global_menu", loops=2, scroll=False)
self.highlight('a[prettyslug*="g-started"]', loops=1, scroll=False)
self.highlight('a[prettyslug="using-slack"]', loops=1, scroll=False)
self.highlight('a[prettyslug="your-profile"]', loops=2, scroll=False)
self.highlight('a[prettyslug="connect-tools"]', loops=1, scroll=False)
self.highlight('a[prettyslug="administration"]', loops=1, scroll=False)
self.highlight('a[prettyslug*="tutorials"]', loops=2, scroll=False)
self.highlight("h1.article_title", loops=5, scroll=False)
self.open("https://kubernetes.io/")
self.set_text_content('nav a[href="/docs/"]', "ALL")
self.set_text_content('nav a[href="/blog/"]', "YOUR")
self.set_text_content('nav a[href="/training/"]', "BASE")
self.set_text_content('nav a[href="/partners/"]', "ARE")
self.set_text_content('nav a[href="/community/"]', "BELONG")
self.set_text_content('nav a[href="/case-studies/"]', "TO")
self.set_text_content("nav #navbarDropdown", "US")
self.set_text_content("nav #navbarDropdownMenuLink", ".")
if self.is_element_visible("h1"):
self.set_text_content("h1", aybabtu)
self.highlight("nav ul.navbar-nav", loops=3, scroll=False)
self.highlight('nav a[href="/docs/"]', loops=1, scroll=False)
self.highlight('nav a[href="/blog/"]', loops=1, scroll=False)
self.highlight('nav a[href="/training/"]', loops=2, scroll=False)
self.highlight('nav a[href="/partners/"]', loops=1, scroll=False)
self.highlight('nav a[href="/community/"]', loops=1, scroll=False)
self.highlight('nav a[href="/case-studies/"]', loops=1, scroll=False)
self.highlight("nav #navbarDropdown", loops=2, scroll=False)
if self.is_element_visible("h1"):
self.highlight("h1", loops=6, scroll=False)
self.open("https://www.selenium.dev/")
if self.is_element_visible('button[data-dismiss="alert"] span'):
self.js_click('button[data-dismiss="alert"] span', scroll=False)
self.set_attributes("a.dropdown-toggle", "class", "nav-link")
self.set_text_content('li a:contains("About")', "ALL")
self.set_text_content('li a:contains("Downloads")', "YOUR")
self.set_text_content('li a:contains("Documentation")', "BASE")
self.set_text_content('li a:contains("Projects")', "ARE")
self.set_text_content('li a:contains("Support")', "BELONG")
self.set_text_content('li a:contains("Blog")', "TO")
self.set_text_content('li a:contains("English")', "US")
self.set_text_content("div.mx-auto p", aybabtu)
self.set_text_content("h2", aybabtu)
if self.is_element_visible('button[data-dismiss="alert"] span'):
self.js_click('button[data-dismiss="alert"] span', scroll=False)
zoom_in = "div.mx-auto p{zoom: 1.1;-moz-transform: scale(1.1);}"
self.add_css_style(zoom_in)
self.highlight("div#main_navbar", loops=1, scroll=False)
self.highlight('li a:contains("ALL")', loops=1, scroll=False)
self.highlight('li a:contains("YOUR")', loops=1, scroll=False)
self.highlight('li a:contains("BASE")', loops=2, scroll=False)
self.highlight('li a:contains("ARE")', loops=1, scroll=False)
self.highlight('li a:contains("BELONG")', loops=1, scroll=False)
self.highlight('li a:contains("TO")', loops=1, scroll=False)
self.highlight('li a:contains("US")', loops=2, scroll=False)
self.highlight("div.mx-auto p", loops=6, scroll=False)
self.highlight("h2", loops=8, scroll=False)
self.open("https://www.python.org/")
self.set_text_content('a[class="donate-button"]', ayb)
self.set_text_content("#about a", "ALL")
self.set_text_content("#downloads a", "YOUR")
self.set_text_content("#documentation a", "BASE")
self.set_text_content("#community a", "ARE")
self.set_text_content("#success-stories a", "BELONG")
self.set_text_content("#news a", "TO")
self.set_text_content("#events a", "US")
self.highlight('a[class="donate-button"]', loops=4, scroll=False)
self.highlight("nav#mainnav", loops=5, scroll=False)
self.highlight("#about a", loops=1, scroll=False)
self.highlight("#downloads a", loops=1, scroll=False)
self.highlight("#documentation a", loops=2, scroll=False)
self.highlight("#community a", loops=1, scroll=False)
self.highlight("#success-stories a", loops=1, scroll=False)
self.highlight("#news a", loops=1, scroll=False)
self.highlight("#events a", loops=2, scroll=False)
self.open("https://docs.pytest.org/")
self.set_text_content("h1", "pytest: " + aybabtu)
self.highlight("h1", loops=10, scroll=False)
self.open("https://wordpress.com/")
zoom_out = "h1{zoom: 0.8;-moz-transform: scale(0.8);}"
self.add_css_style(zoom_out)
zoom_in = "a.wp-element-button{zoom: 1.4;-moz-transform: scale(1.4);}"
self.add_css_style(zoom_in)
self.set_text_content("h1", aybabtu)
self.set_text_content("a.wp-element-button", "Use SeleniumBase!")
self.highlight("h1", loops=8, scroll=False)
self.highlight("a.wp-element-button", loops=8, scroll=False)
self.open("https://seleniumbase.com/")
self.set_text_content("h1", aybabtu)
self.highlight("h1", loops=10, scroll=False)
self.open("https://pypi.org/")
self.set_text_content('a[href="/sponsors/"]', aybabtu)
self.set_text_content("h1", aybabtu)
self.set_value("input#search", aybabtu, scroll=False)
self.highlight('a[href="/sponsors/"]', loops=6, scroll=False)
self.highlight("h1", loops=6, scroll=False)
self.highlight("input#search", loops=8, scroll=False)
self.open("https://status.iboss.com/ibcloud/app/cloudStatus.html")
self.wait_for_element_clickable('div[translate*="cloudStatus"]')
self.set_text_content('div[translate*="cloudStatus"]', ayb)
self.set_text_content('div[translate*="maintenance"]', "ARE")
self.set_text_content('div[translate*="advisory"]', "BELONG")
self.set_text_content('div[translate*="incident"]', "TO US")
self.set_text_content("h1", "Cloud Status - " + aybabtu)
self.highlight("nav div.ibcloud-header-contents", loops=3)
self.highlight('div[translate*="cloudStatus"]', loops=4)
self.highlight('div[translate*="maintenance"]', loops=1)
self.highlight('div[translate*="advisory"]', loops=1)
self.highlight('div[translate*="incident"]', loops=3)
self.highlight("h1", loops=9, scroll=False)
self.open("https://git-scm.com/")
self.set_text_content("span#tagline", aybabtu)
self.set_text_content("#nav-about h3", ayb)
self.set_text_content("#nav-documentation h3", abtu)
self.highlight("span#tagline", loops=8, scroll=False)
self.highlight("#nav-about h3", loops=5, scroll=False)
self.highlight("#nav-documentation h3", loops=6, scroll=False)
self.open("https://pragprog.com/")
self.set_text_content("header p", aybabtu)
zoom_in = "header p{zoom: 1.35;-moz-transform: scale(1.35);}"
self.add_css_style(zoom_in)
self.highlight("header p", loops=10, scroll=False)
self.open("https://seleniumbase.io/")
self.set_text_content("h1", aybabtu)
self.highlight("h1", loops=10, scroll=False)