Best Python code snippet using pyatom_python
testArticleEmbedQuotesTest.py
Source:testArticleEmbedQuotesTest.py
...12 13 embeddedQuote = "https://www.facebook.com/Cosmopolitan/photos/a.466145602707.256721.8358247707/10152569743452708/?type=1&theater"14 formattedQuote = '[facebook align="left" ]https://www.facebook.com/Cosmopolitan/photos/a.466145602707.256721.8358247707/10152569743452708/?type=1&theater[/facebook]'15 addArticlePage.setArticleEmbedQuote(embeddedQuote,"facebook")16 addArticlePage.popUpButtons(1)17 18 addArticlePage.save()19 self.driver.refresh()20 addArticlePage.clickHtmlView(1)21 getHtmlText = addArticlePage.getHtmlBody()22 time.sleep(1)23 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")24 25 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())26 articlePage = ArticlePage.ArticlePage(self.driver)27 time.sleep(1)28 self.assertEqual(embeddedQuote,articlePage.getFacebookEmbeddedQuoteUrl(),"Embedded Quote Not Visible on Front End")29 def testArticleTwitterEmbedQuotes(self):30 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 31 addArticlePage.getRandomEditorialArticle()32 33 embeddedQuote = "https://twitter.com/Cosmopolitan/status/497188627408224257"34 formattedQuote = '[twitter align="left" ]https://twitter.com/Cosmopolitan/status/497188627408224257[/twitter]'35 addArticlePage.setArticleEmbedQuote(embeddedQuote,"twitter")36 addArticlePage.popUpButtons(1)37 38 addArticlePage.save()39 self.driver.refresh()40 addArticlePage.clickHtmlView(1)41 getHtmlText = addArticlePage.getHtmlBody()42 time.sleep(2)43 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")44 45 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())46 articlePage = ArticlePage.ArticlePage(self.driver)47 time.sleep(1)48 print "Test Skips From Here, having hard time locating element on frontend"49 #print self.run.getTwitterEmbeddedQuoteUrl()50 #self.assertEqual(embeddedQuote,self.run.getFacebookEmbeddedQuoteUrl(),"Embedded Quote Not Visible on Front End")51 52 def testArticleYoutubeEmbedQuotes(self):53 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 54 addArticlePage.getRandomEditorialArticle()55 56 embeddedQuote = "http://youtube.com/watch?v=DChmTb-c9uM"57 formattedQuote = '[youtube align="left" ]http://youtube.com/watch?v=DChmTb-c9uM[/youtube]'58 addArticlePage.setArticleEmbedQuote(embeddedQuote,"youtube")59 addArticlePage.popUpButtons(1)60 61 addArticlePage.save()62 self.driver.refresh()63 addArticlePage.clickHtmlView(1)64 getHtmlText = addArticlePage.getHtmlBody()65 time.sleep(1)66 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")67 68 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())69 self.run = ArticlePage.ArticlePage(self.driver)70 time.sleep(1)71 self.assertEquals(embeddedQuote,'http:'+self.run.getYoutubeEmbeddedQuoteUrl(), "The quote embedded doesn't appears to be on front end")72 73 def testArticleInstagramEmbedQuotes(self):74 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 75 addArticlePage.getRandomEditorialArticle()76 77 embeddedQuote = "https://instagram.com/p/rU3KUzCBYt"78 formattedQuote = '[instagram align="left" ]https://instagram.com/p/rU3KUzCBYt[/instagram]'79 addArticlePage.setArticleEmbedQuote(embeddedQuote,"instagram")80 addArticlePage.popUpButtons(1)81 82 addArticlePage.save()83 self.driver.refresh()84 addArticlePage.clickHtmlView(1)85 getHtmlText = addArticlePage.getHtmlBody()86 time.sleep(1)87 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")88 89 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())90 articlePage = ArticlePage.ArticlePage(self.driver)91 time.sleep(3)92 #print embeddedQuote93 #print articlePage.getInstagramUrl()94 #self.assertNotEquals(embeddedQuote,self.run.getInstagramUrl(), "The quote embedded doesn't appears to be on front end")95 #assert embeddedQuote in self.run.getInstagramUrl()96 assert embeddedQuote in articlePage.getInstagramUrl()97 98 def testArticlePinterestEmbedQuotes(self):99 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 100 addArticlePage.getRandomEditorialArticle()101 102 embeddedQuote = "http://www.pinterest.com/pin/58687601369129110/"103 formattedQuote = '[pinterest align="left" ]http://www.pinterest.com/pin/58687601369129110/[/pinterest]'104 addArticlePage.setArticleEmbedQuote(embeddedQuote,"pinterest")105 addArticlePage.popUpButtons(1)106 107 addArticlePage.save()108 self.driver.refresh()109 addArticlePage.clickHtmlView(1)110 getHtmlText = addArticlePage.getHtmlBody()111 time.sleep(1)112 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")113 114 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())115 articlePage = ArticlePage.ArticlePage(self.driver)116 117 self.assertNotEquals(embeddedQuote,'http:'+articlePage.getPinterestUrl(), "The quote embedded doesn't appears to be on front end")118 119 120 def testArticleVineEmbedQuotes(self):121 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 122 addArticlePage.getRandomEditorialArticle()123 124 embeddedQuote = "https://vine.co/v/MEnqEr3XvxX/"125 formattedQuote = '[vine align="left" ]https://vine.co/v/MEnqEr3XvxX/[/vine]'126 addArticlePage.setArticleEmbedQuote(embeddedQuote,"vine")127 addArticlePage.popUpButtons(1)128 129 addArticlePage.save()130 self.driver.refresh()131 addArticlePage.clickHtmlView(1)132 getHtmlText = addArticlePage.getHtmlBody()133 time.sleep(1)134 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")135 136 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())137 articlePage = ArticlePage.ArticlePage(self.driver)138 139 140 #print articlePage.getVineUrl()141 #self.assertEquals(embeddedQuote,'http:'+self.run.getPinterestUrl(), "The quote embedded doesn't appears to be on front end")142 143 def testArticleVevoEmbedQuotes(self):144 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 145 addArticlePage.getRandomEditorialArticle()146 147 embeddedQuote = "http://www.vevo.com/watch/USCMV1200009"148 formattedQuote = '[vevo align="left" ]http://www.vevo.com/watch/USCMV1200009[/vevo]'149 addArticlePage.setArticleEmbedQuote(embeddedQuote,"vevo")150 addArticlePage.popUpButtons(1)151 152 addArticlePage.save()153 self.driver.refresh()154 addArticlePage.clickHtmlView(1)155 getHtmlText = addArticlePage.getHtmlBody()156 time.sleep(1)157 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")158 159 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())160 articlePage = ArticlePage.ArticlePage(self.driver)161 162 self.assertEquals(embeddedQuote,articlePage.getVevoUrl(), "The quote embedded doesn't appears to be on front end")163 164 165 def testArticleHuluEmbedQuotes(self):166 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 167 addArticlePage.getRandomEditorialArticle()168 169 embeddedQuote = "http://www.hulu.com/embed.html?eid=yup4xmajbdn9tkgmlzydzw"170 formattedQuote = '[hulu align="left" ]http://www.hulu.com/embed.html?eid=yup4xmajbdn9tkgmlzydzw[/hulu]'171 addArticlePage.setArticleEmbedQuote(embeddedQuote,"hulu")172 addArticlePage.popUpButtons(1)173 174 addArticlePage.save()175 self.driver.refresh()176 addArticlePage.clickHtmlView(1)177 getHtmlText = addArticlePage.getHtmlBody()178 time.sleep(1)179 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")180 181 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())182 articlePage = ArticlePage.ArticlePage(self.driver)183 #HULU url uses the same VEVO URL so not writing it184 self.assertEquals(embeddedQuote,articlePage.getVevoUrl(), "The quote embedded doesn't appears to be on front end")185 186 def testArticleSpotifyEmbedQuotes(self):187 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 188 addArticlePage.getRandomEditorialArticle()189 190 embeddedQuote = "https://play.spotify.com/user/spotify_uk_/playlist/5IM4iX708vnCK3TfLtt4jY"191 formattedQuote = '[spotify align="left" ]https://play.spotify.com/user/spotify_uk_/playlist/5IM4iX708vnCK3TfLtt4jY[/spotify]'192 addArticlePage.setArticleEmbedQuote(embeddedQuote,"spotify")193 addArticlePage.popUpButtons(1)194 195 addArticlePage.save()196 self.driver.refresh()197 addArticlePage.clickHtmlView(1)198 getHtmlText = addArticlePage.getHtmlBody()199 time.sleep(1)200 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")201 202 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())203 articlePage = ArticlePage.ArticlePage(self.driver)204 self.assertEquals(embeddedQuote,articlePage.getSpotifyUrl(), "The quote embedded doesn't appears to be on front end")205 206 207 def testArticleMTVEmbedQuotes(self):208 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 209 addArticlePage.getRandomEditorialArticle()210 211 embeddedQuote = "http://www.mtv.com/shows/girl_code/girl-code-the-great-debate-the-approach/1079322/video/#id=1730794"212 videoID = 1730794213 formattedQuote = '[mtv align="left" ]http://www.mtv.com/shows/girl_code/girl-code-the-great-debate-the-approach/1079322/video/#id=1730794[/mtv]'214 addArticlePage.setArticleEmbedQuote(embeddedQuote,"mtv")215 addArticlePage.popUpButtons(1)216 217 addArticlePage.save()218 self.driver.refresh()219 addArticlePage.clickHtmlView(1)220 getHtmlText = addArticlePage.getHtmlBody()221 time.sleep(1)222 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")223 224 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())225 articlePage = ArticlePage.ArticlePage(self.driver)226 if (True == articlePage.getMtvVideoID()):227 self.assertNotEquals(videoID,articlePage.getMtvVideoID(), "The quote embedded doesn't appears to be on front end")228 else:229 raise Exception("Error")230 231 def testArticleFunnyOrDieEmbedQuotes(self):232 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 233 addArticlePage.getRandomEditorialArticle()234 235 embeddedQuote = "http://www.funnyordie.com/videos/c2deb9a5e8/mary-poppins-quits-with-kristen-bell"236 formattedQuote = '[funnyordie align="left" ]http://www.funnyordie.com/videos/c2deb9a5e8/mary-poppins-quits-with-kristen-bell[/funnyordie]'237 addArticlePage.setArticleEmbedQuote(embeddedQuote,"funnyordie")238 addArticlePage.popUpButtons(1)239 240 addArticlePage.save()241 self.driver.refresh()242 addArticlePage.clickHtmlView(1)243 getHtmlText = addArticlePage.getHtmlBody()244 time.sleep(1)245 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")246 247 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())248 articlePage = ArticlePage.ArticlePage(self.driver)249 250 #print articlePage.getFunnyOrDieUrl()251 252 def testArticlePlayBuzzEmbedQuotes(self):253 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 254 addArticlePage.getRandomEditorialArticle()255 256 embeddedQuote = "http://www.playbuzz.com/shaheenaa10/which-disney-royalty-are-you-most-like"257 formattedQuote = '[playbuzz align="left" ]http://www.playbuzz.com/shaheenaa10/which-disney-royalty-are-you-most-like[/playbuzz]'258 addArticlePage.setArticleEmbedQuote(embeddedQuote,"playbuzz")259 addArticlePage.popUpButtons(1)260 261 addArticlePage.save()262 self.driver.refresh()263 addArticlePage.clickHtmlView(1)264 getHtmlText = addArticlePage.getHtmlBody()265 time.sleep(1)266 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")267 268 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())269 articlePage = ArticlePage.ArticlePage(self.driver)270 271 #print articlePage.getPlayBuzzUrl()272 273 274 def testArticleNYMagEmbedQuotes(self):275 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 276 addArticlePage.getRandomEditorialArticle()277 278 embeddedQuote = "http://video.vulture.com/video/Robin-Thicke-In-Making-the-Rule"279 formattedQuote = '[nymag align="left" ]http://video.vulture.com/video/Robin-Thicke-In-Making-the-Rule[/nymag]'280 addArticlePage.setArticleEmbedQuote(embeddedQuote,"nymag")281 addArticlePage.popUpButtons(1)282 283 addArticlePage.save()284 self.driver.refresh()285 addArticlePage.clickHtmlView(1)286 getHtmlText = addArticlePage.getHtmlBody()287 time.sleep(1)288 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")289 290 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())291 articlePage = ArticlePage.ArticlePage(self.driver)292 293 #print articlePage.getNYMAGtitle()294 295 def testArticleVogueEmbedQuotes(self):296 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 297 addArticlePage.getRandomEditorialArticle()298 299 embeddedQuote = "http://player.cnevids.com/embed/53cea3ef69702d13ed0c0000/5176e90368f9daff42000014"300 formattedQuote = '[vogue align="left" ]http://player.cnevids.com/embed/53cea3ef69702d13ed0c0000/5176e90368f9daff42000014[/vogue]'301 addArticlePage.setArticleEmbedQuote(embeddedQuote,"vogue")302 addArticlePage.popUpButtons(1)303 304 addArticlePage.save()305 self.driver.refresh()306 addArticlePage.clickHtmlView(1)307 getHtmlText = addArticlePage.getHtmlBody()308 time.sleep(1)309 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")310 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())311 articlePage = ArticlePage.ArticlePage(self.driver)312 self.assertEquals(embeddedQuote,articlePage.getVogueUrl(),"The quote embedded doesn't appears to be on front end")313 314 def testArticleMediaMattersEmbedQuotes(self):315 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 316 addArticlePage.getRandomEditorialArticle()317 318 embeddedQuote = "http://mediamatters.org/video/2014/07/30/foxs-krauthammer-approves-house-gop-lawsuit-as/200270"319 videoID = "200270"320 formattedQuote = '[mediamatters align="left" ]http://mediamatters.org/video/2014/07/30/foxs-krauthammer-approves-house-gop-lawsuit-as/200270[/mediamatters]'321 addArticlePage.setArticleEmbedQuote(embeddedQuote,"mediamatters")322 addArticlePage.popUpButtons(1)323 324 addArticlePage.save()325 self.driver.refresh()326 addArticlePage.clickHtmlView(1)327 getHtmlText = addArticlePage.getHtmlBody()328 time.sleep(1)329 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")330 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())331 articlePage = ArticlePage.ArticlePage(self.driver)332 #print videoID333 #print self.run.getMediaMattersVideoID()334 assert videoID in articlePage.getMediaMattersVideoID()335 336 def testArticleTMZEmbedQuotes(self):337 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 338 addArticlePage.getRandomEditorialArticle()339 340 embeddedQuote = "http://cdnapi.kaltura.com/index.php/kwidget/wid/1_7y67f2tq/uiconf_id/6740162/st_cache/85457"341 videoID = "200270"342 formattedQuote = '[tmz align="left" ]http://cdnapi.kaltura.com/index.php/kwidget/wid/1_7y67f2tq/uiconf_id/6740162/st_cache/85457[/tmz]'343 addArticlePage.setArticleEmbedQuote(embeddedQuote,"tmz")344 addArticlePage.popUpButtons(1)345 346 addArticlePage.save()347 self.driver.refresh()348 addArticlePage.clickHtmlView(1)349 getHtmlText = addArticlePage.getHtmlBody()350 time.sleep(1)351 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")352 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())353 articlePage = ArticlePage.ArticlePage(self.driver)354 #print articlePage.getTMZID()355 #assert videoID in self.run.getMediaMattersVideoID()356 357 def testArticleABCVideoEmbedQuotes(self):358 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 359 addArticlePage.getRandomEditorialArticle()360 361 embeddedQuote = "http://abc.go.com/shows/the-bachelor/video/most-recent/VDKA0_giw9s1nh"362 formattedQuote = '[abcvideo align="left" ]http://abc.go.com/shows/the-bachelor/video/most-recent/VDKA0_giw9s1nh[/abcvideo]'363 videoID = "VDKA0_giw9s1nh"364 addArticlePage.setArticleEmbedQuote(embeddedQuote,"abcvideo")365 addArticlePage.popUpButtons(1)366 367 addArticlePage.save()368 self.driver.refresh()369 addArticlePage.clickHtmlView(1)370 getHtmlText = addArticlePage.getHtmlBody()371 time.sleep(1)372 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")373 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())374 articlePage = ArticlePage.ArticlePage(self.driver)375 self.assertEqual(videoID, articlePage.getAbcVideoUrl(), "The quote embedded doesn't appears to be visible on frontend")376 def testArticleSoundCloudEmbedQuotes(self):377 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 378 addArticlePage.getRandomEditorialArticle()379 380 embeddedQuote = "https://soundcloud.com/otherpeoplerecords/03-adsr-toms"381 formattedQuote = '[soundcloud align="left" ]https://soundcloud.com/otherpeoplerecords/03-adsr-toms[/soundcloud]'382 videoID = "VDKA0_giw9s1nh"383 addArticlePage.setArticleEmbedQuote(embeddedQuote,"soundcloud")384 addArticlePage.popUpButtons(1)385 386 addArticlePage.save()387 self.driver.refresh()388 addArticlePage.clickHtmlView(1)389 getHtmlText = addArticlePage.getHtmlBody()390 time.sleep(1)391 self.assertEqual(formattedQuote,getHtmlText, "Text isn't equal")392 addArticlePage.loadUrl(addArticlePage.getPreviewUrl())393 articlePage = ArticlePage.ArticlePage(self.driver)394 #print articlePage.getSoundCloudUrl()395 #self.assertEqual(videoID, self.run.getAbcVideoUrl(), "The quote embedded doesn't appears to be visible on frontend")396 def testArticleTwiigspollEmbedQuotes(self):397 addArticlePage = AP.AddArticlePage(self.driver,"m.php?t=articles") 398 addArticlePage.getRandomEditorialArticle()399 400 embeddedQuote = "[twiigspoll id='11749' align='left' ]"401 formattedQuote = "[twiigspoll id='11749' align='left' ]"402 addArticlePage.setArticleEmbedQuote(embeddedQuote,"twiigspoll")403 addArticlePage.popUpButtons(1)404 405 addArticlePage.save()406 self.driver.refresh()407 addArticlePage.clickHtmlView(1)408 getHtmlText = addArticlePage.getHtmlBody()409 time.sleep(1)410 assert formattedQuote in getHtmlText411 412if __name__ == "__main__":...
mathQuestion.py
Source:mathQuestion.py
1#FILE DESCRIPTION: This file manages the math aspect of the game.2import pygame3import random4import classes5import images6#import math7#import data8import objects9def generateQuestions():10 question1 = ''11 question2 = ''12 answer1 = 013 answer2 = 014 answer3 = 015 answer4 = 016 operations = ['+', '-', '/', '*']17 objects.popUpBox = True18 randNums = [random.randint(1, 100),random.randint(1, 100), random.randint(1, 100), random.randint(1, 100)]19 positions = [0,0,0,0]20 positions[random.randint(0,3)] = 121 # searching22 # while searching 23 # guess random position24 # if position empty25 # searching is false and fill position26 searching = True27 while searching:28 r = random.randint(0,3)29 if 0 == positions[r]:30 positions[r] = 231 searching = False32 searching = True33 while searching:34 r = random.randint(0,3)35 if 0 == positions[r]:36 positions[r] = 337 searching = False38 searching = True39 while searching:40 r = random.randint(0,3)41 if 0 == positions[r]:42 positions[r] = 443 searching = False44 print(positions)45 currentOperator = operations[random.randint(0,3)]46 47 question1 = str(randNums[0]) + currentOperator + str(randNums[1])48 if currentOperator == '/':49 question1 = str(randNums[0]) + currentOperator + str(randNums[1]) + '. Round down.'50 if currentOperator == '+':51 answer1 = randNums[0] + randNums[1]52 if currentOperator == '-':53 answer1 = randNums[0] - randNums[1]54 if currentOperator == '*':55 answer1 = randNums[0] * randNums[1]56 if currentOperator == '/':57 answer1 = randNums[0] // randNums[1]58 59 currentOperator = operations[random.randint(0,3)]60 question2 = str(randNums[2]) + currentOperator + str(randNums[3])61 if currentOperator == '/':62 question2 = str(randNums[2]) + currentOperator + str(randNums[3]) + '. Round down.'63 if currentOperator == '+':64 answer2 = randNums[2] + randNums[3]65 if currentOperator == '-':66 answer2 = randNums[2] - randNums[3]67 if currentOperator == '*':68 answer2 = randNums[2] * randNums[3]69 if currentOperator == '/':70 answer2 = randNums[2] // randNums[3]71 currentOperator = operations[random.randint(0,3)]72 question3 = str(randNums[2]) + currentOperator + str(randNums[3])73 if currentOperator == '/':74 question3 = str(randNums[2]) + currentOperator + str(randNums[3]) + '. Round down.'75 if currentOperator == '+':76 answer3 = randNums[2] + randNums[3]77 if currentOperator == '-':78 answer3 = randNums[2] - randNums[3]79 if currentOperator == '*':80 answer3 = randNums[2] * randNums[3]81 if currentOperator == '/':82 answer3 = randNums[2] // randNums[3]83 currentOperator = operations[random.randint(0,3)]84 question4 = str(randNums[2]) + currentOperator + str(randNums[3])85 if currentOperator == '/':86 question4 = str(randNums[2]) + currentOperator + str(randNums[3]) + '. Round down.'87 if currentOperator == '+':88 answer4 = randNums[2] + randNums[3]89 if currentOperator == '-':90 answer4 = randNums[2] - randNums[3]91 if currentOperator == '*':92 answer4 = randNums[2] * randNums[3]93 if currentOperator == '/':94 answer4 = randNums[2] // randNums[3]95 # Things to put inside popUpBox: Questions, Answers, Background96 # Draw Background97 pygame.font.init()98 spacing = 1599 popUpBoxFont = pygame.font.Font("Fonts/hamberger.ttf", 30)100 question1 = popUpBoxFont.render(question1, True, (0,0,0))101 question2 = popUpBoxFont.render(question2, True, (0,0,0))102 answer1 = popUpBoxFont.render(str(answer1), True, (0,0,0))103 answer2 = popUpBoxFont.render(str(answer2), True, (0,0,0))104 answer3 = popUpBoxFont.render(str(random.randint(-100,100)), True, (0,0,0))105 answer4 = popUpBoxFont.render(str(random.randint(-100,100)), True, (0,0,0))106 tempdata = [answer1, answer2, answer3, answer4]107 answer1 = tempdata[positions[0]-1]108 answer2 = tempdata[positions[1]-1]109 answer3 = tempdata[positions[2]-1]110 answer4 = tempdata[positions[3]-1]111 # Create a new place to save our old data112 # Copy answers 1-4 into the list but in the right place113 # Copy them back into their respective locations114 questionWidth = question1.get_size()[0] + spacing * 3 + question2.get_size()[0]115 answerWidth = answer1.get_size()[0] + spacing * 5 + answer2.get_size()[0] + answer3.get_size()[0] + answer4.get_size()[0]116 117 if questionWidth < answerWidth:118 objects.popUpBoxImage = pygame.Surface((answerWidth, 200))119 else:120 objects.popUpBoxImage = pygame.Surface((questionWidth, 200))121 122 objects.popUpBoxImage.fill((255,255,255))123 objects.popUpBoxImage.blit(question1, (spacing,0))124 objects.popUpBoxImage.blit(question2, (spacing * 2 + question1.get_size()[0],0))125 #objects.popUpBoxImage.blit(question3, (spacing * 3 + question1.get_size()[0],100))126 #objects.popUpBoxImage.blit(question4, (spacing * 4 + question1.get_size()[0],100))127 xAns1 = question1.get_size()[0]/2 - answer1.get_size()[0]/2 + spacing128 xAns2 = question2.get_size()[0]/2 - answer2.get_size()[0]/2 + spacing * 2 + question1.get_size()[0]129 xAns3 = question1.get_size()[0]/2 - answer3.get_size()[0]/2 + spacing130 xAns4 = question2.get_size()[0]/2 - answer4.get_size()[0]/2 + spacing * 2 + question1.get_size()[0]131 objects.popUpBoxImage.blit(answer1, (xAns1, 100))132 objects.popUpBoxImage.blit(answer2, (xAns2, 100))133 objects.popUpBoxImage.blit(answer3, (xAns3, 150))134 objects.popUpBoxImage.blit(answer4, (xAns4, 150))135 #objects.popUpBoxImage.blit(answer5, (spacing,150))136 #objects.popUpBoxImage.blit(answer6, (spacing * 2 + answer1.get_size()[0],150))137 #objects.popUpBoxImage.blit(answer7, (spacing * 3 + answer1.get_size()[0], 150))138 #objects.popUpBoxImage.blit(answer8, (spacing * 4 + answer1.get_size()[0], 150))139 140 objects.popUpBoxRect = objects.popUpBoxImage.get_rect()141 objects.popUpBoxRect.center = objects.gameRect.center142 objects.popUpButtons = []143 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((spacing + objects.popUpBoxRect.x, objects.popUpBoxRect.y), question1.get_size()), ['objects.selectedAnswer = 1']))144 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((spacing * 2 + question1.get_size()[0] + objects.popUpBoxRect.x, objects.popUpBoxRect.y), question2.get_size()), ['objects.selectedAnswer = 2']))145 146 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((xAns1 + objects.popUpBoxRect.x, 100 + objects.popUpBoxRect.y), answer1.get_size()), ['objects.popUpBox = False', f'if {positions[0]} != objects.selectedAnswer: objects.currentBoss.health = objects.currentBoss.health * 2; print("wrong answer")']))147 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((xAns2 + objects.popUpBoxRect.x, 100 + objects.popUpBoxRect.y), answer2.get_size()), ['objects.popUpBox = False', f'if {positions[1]} != objects.selectedAnswer: objects.currentBoss.health = objects.currentBoss.health * 2; print("wrong answer")']))148 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((xAns3 + objects.popUpBoxRect.x, 150 + objects.popUpBoxRect.y), answer3.get_size()), ['objects.popUpBox = False', f'if {positions[2]} != objects.selectedAnswer: objects.currentBoss.health = objects.currentBoss.health * 2; print("wrong answer")']))149 objects.popUpButtons.append(classes.Button(images.blue, pygame.Rect((xAns4 + objects.popUpBoxRect.x, 150 + objects.popUpBoxRect.y), answer4.get_size()), ['objects.popUpBox = False', f'if {positions[3]} != objects.selectedAnswer: objects.currentBoss.health = objects.currentBoss.health * 2; print("wrong answer")']))150 '''151 # FONT PRACTICE152 ['dejavuserif', 'dejavusansmono', 'freesans', 'dejavusans', 'freeserif', 'freemono', None]153 JonnyFont = pygame.font.Font("Fonts/PermanentMarker.ttf", 50)154 AdrianFont = pygame.font.Font(pygame.font.match_font("freemono"), 20)155 AndrewFont = pygame.font.Font("Fonts/hamberger.ttf", 70)156 # Font.render(text, antialias, color, background=None)157 JonnyImg = JonnyFont.render("qwertyuiopasdfghjklzxcvbnm", True, (0,0,0))158 AdrianImg = AdrianFont.render("Hello World", True, (0, 0, 0))159 AndrewImg = AndrewFont.render("hello world",True,(0,0,0))160 objects.popUpBoxImage.blit(JonnyImg,(0,0))161 objects.popUpBoxImage.blit(AdrianImg,(0,50))162 objects.popUpBoxImage.blit(AndrewImg,(0,70))...
AppleID.py
Source:AppleID.py
...66 time.sleep(0.5)67 window.sendKey('<backspace>')68 time.sleep(0.5)69 group.groups()[2].groups()[3].textFields()[0].setString("AXValue", password)70 group.groups()[5].groups()[0].popUpButtons()[0].Press()71 time.sleep(0.5)72 window.sendKey('<cursor_down>')73 time.sleep(0.5)74 window.sendKey('<num_enter>')75 time.sleep(0.5)76 group.groups()[5].groups()[1].textFields()[0].setString("AXValue", answer1)77 group.groups()[6].groups()[0].popUpButtons()[0].Press()78 time.sleep(0.5)79 window.sendKey('<cursor_down>')80 time.sleep(0.5)81 window.sendKey('<num_enter>')82 time.sleep(0.5)83 group.groups()[6].groups()[1].textFields()[0].setString("AXValue", answer2)84 group.groups()[7].groups()[0].popUpButtons()[0].Press()85 time.sleep(0.5)86 window.sendKey('<cursor_down>')87 time.sleep(0.5)88 window.sendKey('<num_enter>')89 time.sleep(0.5)90 group.groups()[7].groups()[1].textFields()[0].setString("AXValue", answer3)91 group.groups()[12].groups()[0].popUpButtons()[0].Press()92 time.sleep(0.5)93 window.sendKey('<cursor_down>')94 time.sleep(0.5)95 window.sendKey('<num_enter>')96 time.sleep(0.5)97 group.groups()[12].groups()[1].popUpButtons()[0].Press()98 time.sleep(0.5)99 window.sendKey('<cursor_down>')100 time.sleep(0.5)101 window.sendKey('<num_enter>')102 time.sleep(0.5)103 group.groups()[12].groups()[2].textFields()[0].setString("AXValue", year)104 getContent(window).buttons('Continue')[0].Press()105 time.sleep(8)106 group = getContent(window).groups()[1]107 group.groups()[6].groups()[0].popUpButtons()[0].Press()108 time.sleep(0.5)109 window.sendKey('<cursor_down>')110 time.sleep(0.5)111 window.sendKey('<num_enter>')112 time.sleep(0.5)113 group.groups()[7].groups()[0].textFields()[0].setString("AXValue", lastName)114 group.groups()[7].groups()[1].textFields()[0].setString("AXValue", firstName)115 group.groups()[8].groups()[0].textFields()[0].setString("AXValue", street)116 group.groups()[9].groups()[0].textFields()[0].setString("AXValue", index)117 group.groups()[9].groups()[1].textFields()[0].setString("AXValue", city)118 group.groups()[10].groups()[0].textFields()[0].setString("AXValue", cityCode)119 group.groups()[10].groups()[1].textFields()[0].setString("AXValue", phoneNumber)120 time.sleep(0.5)121 getContent(window).buttons('Create Apple ID')[0].Press()...
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!!