def test_07_wycs(self): """Tests the What-You-Can-See-Mosaic-related functionality.""" # Navigate to the Three Days Itineraries page try: if self.globs['cn_mode']: CP.NavMenu.ExploreAndPlan(self.dr).open().city_journeys().click() else: CP.NavMenu.ThingsToDo(self.dr).open().city_journeys().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).city_journeys() # Click on a tile, should direct to the correct page while the other tiles grey out try: CP.WhatYouCanSeeMosaic(self.dr).random_selection(1)[0].go() # Some of them go to external sites which open in a new tab. self.dr.close_other_windows() except Exception: self.add_error() self.dr.close_other_windows() # Go to the Great Barrier Reef page try: CP.NavMenu.PlacesToGo(self.dr).open().great_barrier_reef().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).great_barrier_reef() # Click on a tile, should direct to the correct page, other tiles faded CP.WhatYouCanSeeMosaic(self.dr).random_selection(1)[0].go()
def test_07_Mosaic(self) -> None: """Tests the Mosaic functionality, and that the PDFs are hosted correctly.""" self.dr.open_home_page() # Go to a page with a Mosaic with self.restraint('Why Australia link is missing from the nav', CP.BackupHrefs(self.dr).why_australia): CP.NavMenu.WhyAustralia(self.dr).open().why_australia().click() # Find the mosaic with self.restraint('Mosaic comonent missing from the page', TimeoutException='Tile did not link to its page'): mos = CP.WhatYouCanSeeMosaic(self.dr) mos.random_selection(1)[0].go() # In case it was an external link self.dr.close_other_windows() # Find a page with PDFs Included with self.restraint('Data Room link is missing from the nav', CP.BackupHrefs(self.dr).data_room): CP.NavMenu.DataRoom(self.dr).open().data_room().click() with self.restraint( 'Second Mosaic component is missing', AssertionError='A PDF link did not go to the right environment' ): mos = CP.WhatYouCanSeeMosaic(self.dr, 1) for tile in mos: # Eeh, the AUTH throws it off a bit. Trim https bit to compensate self.assertIn(self.globs['base_url'][8:], tile.get_link())
def test_10_Sitemap(self) -> None: """Tests the Sitemap functionality.""" self.dr.open_home_page() # Go to the sitemap page, and get the Sitemap with self.restraint('Cannot get to sitemap page via footer nav', CP.BackupHrefs(self.dr).sitemap): CP.Footer(self.dr).sitemap().click() with self.destruction('Sitemap is missing from the sitemap page'): sma = CP.Sitemap(self.dr) # Sitemap should have links to each of the pages in the Nav Menu with self.restraint( 'Could not collect list of nav/sitemap links', AssertionError='The sitemap/nav menu link sets do not match'): nav_links = CP.NavMenu(self.dr).get_all_links() sitemap_links = sma.get_all_links() self.assertTrue(nav_links.issubset(sitemap_links)) # And should also links corresponding to the footer links with self.restraint( 'Could not collect the list of footer links', AssertionError='The sitemap/footer link sets do not match'): fo = CP.Footer(self.dr) fo_li = fo.get_all_links() self.assertTrue(fo_li.issubset(sitemap_links)) # And, a bit for the languages with self.restraint( 'Could not collect the list of locales', AssertionError='The sitemap/footer locales sets do not match'): self.assertSetEqual(set(fo.get_locales()), sma.get_locales())
def test_09_FilteredSearch(self) -> None: """Tests the Filtered Search functionality.""" self.dr.open_home_page() # Go to the Contact Us page with self.restraint( 'Cannot get to the Contact Us page via the footer link', CP.BackupHrefs(self.dr).contact_inv): CP.Footer(self.dr).contact_us().click() # Get the contact Search with self.destruction( 'The Contact Us page is missing the Filtered Search component' ): fil = CP.FilteredSearch(self.dr) with self.destruction('No contact search results are present'): ress = fil.get_all_results() # Check each of the results has a name, an email address, and a phone link with self.restraint('Results are missing fields'): for res in ress: res.email() res.phone() self.assertGreater(res.name(), '') # Add some filters, and confirm that filtering did, in fact, occur with self.restraint( 'Unable to apply a search filter', AssertionError= 'Filtering the search did not change the results present'): fil.random_search() self.assertNotEqual(ress, fil.get_all_results())
def test_11_explore(self): """Tests the Explore component.""" # Navigate to the Sydney page try: CP.NavMenu.PlacesToGo(self.dr).open().sydney().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).sydney() # Click the Location Pin button on a the Explore component cards = CP.Explore(self.dr).cards for card in cards: card.flip() # Confirm that the card flipped for card in cards: self.assertTrue(card.is_flipped()) # Click the back to overview button for card in cards: card.unflip() for card in cards: self.assertFalse(card.is_flipped()) # Add some to favourites count = CP.HeaderHeartIcon(self.dr).favourites_count() for card in cards: card.add_to_favourites() # Confirm favourites incremented self.dr.wait_until(lambda: count + 3 == CP.HeaderHeartIcon(self.dr).favourites_count(), 'count + 3 equals favourites.count.')
def test_04_favourites(self): """Tests the My Dream Trip functionality.""" # Go to the Australia's Animals page try: if self.globs['cn_mode']: CP.NavMenu.PracticalInformation(self.dr).open().australias_animals().click() else: CP.NavMenu.PlanYourTrip(self.dr).open().facts().click() CP.WhatYouCanSeeMosaic(self.dr)["Australia's Animals"].click() except Exception: self.add_error() CP.BackupHrefs(self.dr).australias_animals() try: # Click the Add To Favourites button favcount = CP.HeaderHeartIcon(self.dr).favourites_count() + 1 CP.ShareThis(self.dr).add_to_favourites() # Wait for the animation to finish and for confirmation of incremention self.dr.wait_until(lambda: CP.HeaderHeartIcon(self.dr).favourites_count() == favcount, 'Heart Icon count == favcount.') # Do that again with the Regional Cities page. try: CP.NavMenu.PlacesToGo(self.dr).open().regional_cities().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).regional_cities() # Do this again, because the heart count doesn't load at the same time as the page. self.dr.wait_until(lambda: CP.HeaderHeartIcon(self.dr).favourites_count() == favcount, 'Heart Icon count == favcount.') favcount = CP.HeaderHeartIcon(self.dr).favourites_count() + 1 CP.ShareThis(self.dr).add_to_favourites() self.dr.wait_until(lambda: CP.HeaderHeartIcon(self.dr).favourites_count() == favcount, 'Heart Icon count == favcount.') except Exception: self.add_error() # Go to favourites page. I would put a try-navigate here, but it's a dynamic url. CP.HeaderHeartIcon(self.dr).click() # Remove a favourite favs = CP.MySalesTools(self.dr).get_favourites() oldfavs = {f.get_title() for f in favs} rem = random.choice(favs) oldfavs.remove(rem.get_title()) rem.close() # Confirm it was removed self.dr.refresh() favs = CP.MySalesTools(self.dr).get_favourites() self.assertSetEqual(oldfavs, {f.get_title() for f in favs})
def test_03_Share(self) -> None: """Tests the ShareThis functionality""" self.dr.open_home_page() # Open a page with a Share component and click the Share button with self.restraint('Why Australia link missing from nav', CP.BackupHrefs(self.dr).why_australia): CP.NavMenu.WhyAustralia(self.dr).open().why_australia().click() # Confirm the AddThis window appears, and is populated with the page title with self.destruction( 'Share button missing from the page', AssertionError='Page title is not shown in the share popup'): self.assertIn( CP.ShareThis(self.dr).open_share(), self.dr.page_title())
def test_09_brightcove(self): """Tests the Brightcove Video Player.""" # Go to the Tasmania page try: pla = CP.NavMenu.PlacesToGo(self.dr).open() pla.states().click() pla.tas().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).tas() # Play the video. vid = CP.Video(self.dr) vid.play()
def test_08_special_offers(self): """Tests the Special Offers page""" # Navigate to the Special Offers page try: if self.globs['cn_mode']: CP.NavMenu.ExploreAndPlan(self.dr).open().specialoffers().click() else: CP.NavMenu.ThingsToDo(self.dr).open().campaigns().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).offers() # Click on a Special Offers link CP.SpecialOffer(self.dr).view_more_information()
def test_06_Brightcove(self) -> None: """Tests the Brightcove Video functionality""" self.dr.open_home_page() # Find a video with self.restraint('Tourism Demand Strategy link is missing', CP.BackupHrefs(self.dr).tourism_demand_strategy): CP.NavMenu.WhyAustralia( self.dr).open().tourism_demand_strategy().click() with self.destruction( 'Video is missing from the page', TimeoutException='Video does not play when clicked'): vide = CP.Video(self.dr) vide.play() self.dr.wait_until(vide.is_playing, 'Waiting for video to be in the Playing state')
def test_02_Hero(self) -> None: """Tests the Hero Banner's Pin It button, mostly""" self.dr.open_home_page() # Open a page with a Hero Banner with self.restraint('Why Australia link missing from nav', CP.BackupHrefs(self.dr).why_australia): CP.NavMenu.WhyAustralia(self.dr).open().why_australia().click() # Find the banner and click the Pin It button with self.destruction('Hero banner Pin It button is missing'): CP.Hero(self.dr).pin_it() # Confirm the Pinterest window opens in a new window with self.restraint( IndexError='Pinterest link did not open in new window', TimeoutException='Pin It button did not open Pinterest site.'): self.dr.switch_to_window(1) self.dr.wait_for_page('pinterest.com')
def test_05_whitsundays(self): """Tests various things pertaining to Itinerary pages.""" # Navigate to Whitsundays Sailing try: if self.globs['cn_mode']: CP.NavMenu.ExploreAndPlan(self.dr).open().coastal_journeys().click() CP.WhatYouCanSeeMosaic(self.dr)['圣灵群岛航海游'].go() else: CP.NavMenu.ThingsToDo(self.dr).open().coastal_journeys().click() CP.WhatYouCanSeeMosaic(self.dr)['Whitsundays Sailing'].go() except Exception: self.add_error() CP.BackupHrefs(self.dr).whitsundays() # Click a few of the Itinerary Day links iti = CP.ItineraryDay(self.dr) # Get the scroll position of that bit. scr = self.dr.current_scroll() iti.random_link() # Confirm scrolling has taken place? self.assertNotEqual(scr, self.dr.current_scroll()) iti.back_to_top() self.assertEqual(0, self.dr.current_scroll())
def test_02_kdp(self): """Tests the KDP Partner Search functionality.""" if not self.globs['cn_mode']: self.skipTest('Only China has the KDP thing.') # Navigate to the KDP page try: CP.NavMenu.ExploreAndPlan(self.dr).open().kdp().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).kdp() # Count results, assert all buttons lit. kdp = CP.KDPSearch(self.dr) # North China, South China, East China and West China icons should all be active self.assertEqual(len(kdp.lit_icons()), 4) total = kdp.total_results() subtotal = 0 # Click the South China button kdp.south() # The South China icon should remain cyan while the others turn white. self.assertEqual(kdp.lit_icons(), 's') self.assertLessEqual(kdp.total_results(), total) subtotal += kdp.total_results() # Do that for the remaining three regions (North China, East China and West China) kdp.east() self.assertEqual(kdp.lit_icons(), 'e') self.assertLessEqual(kdp.total_results(), total) subtotal += kdp.total_results() kdp.west() self.assertEqual(kdp.lit_icons(), 'w') self.assertLessEqual(kdp.total_results(), total) subtotal += kdp.total_results() kdp.north() self.assertEqual(kdp.lit_icons(), 'n') self.assertLessEqual(kdp.total_results(), total) subtotal += kdp.total_results() # And make sure that they all add to the total. self.assertEqual(total, subtotal)
def test_01_social(self): """Tests the various Social Sharing components. WeChat/Weibo in CN, ShareThis elsewhere. Does not test the QR code links, can't seem to do that.""" # Navigate to any page (e.g. http://www.australia.cn/zh-cn/planning/getting-around.html) try: if self.globs['cn_mode']: CP.NavMenu.PracticalInformation(self.dr).open().getting_around().click() else: CP.NavMenu.PlanYourTrip(self.dr).open().getting_around().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).getting_around() # ShareThis compoent bit: try: # Click the Share icon share = CP.ShareThis(self.dr) share.open_share() if self.globs['cn_mode']: # Two icons should slide out from under it # Click the icon for WeChat (two chat balloon faces) share.open_wechat() qur = CP.QRCode(self.dr) # TODO: A QR code should appear, scan it. # self.dr.get(qur.decode()) # TODO: Implement result: "The corresponding page opens in WeChat" # self.assertEqual(self.dr.current_url(), 'who even knows') # self.dr.back() # Close the QR code. qur.close() # Take some notes on the page for later comparison. desc = share.page_description() # img = share.page_image() url = self.dr.current_url() # Click the icon for Weibo (eyeball thing) share.open_weibo() # A window should pop up linking to service.weibo.com self.dr.switch_to_window(1) # It should contain the description of, images pulled from, # and a minified link to, the page weibo = CP.WeiboShare(self.dr) self.assertEqual(desc, weibo.page_description(), 'The Weibo message should default ' 'to the page description.') # The page image should be there, but the image filenames are all parameterized, # there's no way to confirm that it's the right image other than looking at it. # self.assertEqual(img, weibo.page_image(), "The page's image should be listed.") self.dr.get(weibo.miniurl()) self.assertEqual(url, self.dr.current_url(), "The Weibo mini-url should resolve to " "the page's url.") self.dr.close_window() else: # TODO: Global Share Icon behaviour. self.skipTest("Haven't done global share component yet.") except Exception: self.add_error() self.dr.close_other_windows() # Footer bit: try: if self.globs['cn_mode']: # Click on the WeChat QR code/link in the footer footer = CP.Footer(self.dr) footer.wechat().click() # A QR code should appear in an overlay qur = CP.QRCode(self.dr) # TODO: Implement action: "Scan the QR code using your WeChat app" # self.dr.get(qur.decode()) # TODO: Implement result: "The WeChat account belonging to TA China shows up" # self.assertEqual(self.dr.current_url(), 'who even knows') # self.dr.back() qur.close() # Click on the Sina Weibo image link footer.weibo().click() # A new tab/window opens to TA's Sina Weibo account (login to Sina Weibo required) self.dr.switch_to_window(1) # TODO: Maybe set up a weibo account and log in properly? self.assertRegex(self.dr.current_url(), 'weibo.com/(login.php|.+?seeaustralia)', 'The link should go to the AUS.com Weibo page, ' 'or it may redirect to a login page.') self.dr.close_window() else: # TODO: Handle the global footer social media links self.skipTest("Haven't done global social links yet.") except Exception: self.add_error() self.dr.close_other_windows() # Navigate to the Aquatics page try: if self.globs['cn_mode']: CP.NavMenu.ExploreAndPlan(self.dr).open().aquatic().click() else: CP.NavMenu.ThingsToDo(self.dr).open().aquatic().click() except Exception: self.add_error() CP.BackupHrefs(self.dr).aquatic() pan = CP.PanoramicCarousel(self.dr) # Take some notes on the page for later comparison. # Click the watch video button desc, _ = pan.watch_video() # Click the other start video button pan.once_off_start_video() # Open the Menu, might not need to do this if you are fast enough # pan.open_video_menu() if self.globs['cn_mode']: # Click the WeChat icon pan.wechat() # A QR code appears qur = CP.QRCode(self.dr) # TODO: Implement action: "Scan the QR code using the WeChat app on your phone" # TODO: Implement result: "The corresponding page opens in WeChat" qur.close() # Click the Weibo icon pan.weibo() # A window should pop up linking to service.weibo.com self.dr.switch_to_window(1) # It should contain the description of, images pulled from, # and a minified link to, the video weibo = CP.WeiboShare(self.dr) self.assertEqual(desc, weibo.page_description(), 'The Weibo message should default' ' to the video description.') # The page image should be there, but the image filenames are all parameterized, # there's no way to confirm that it's the right image other than looking at it. # self.assertEqual(img, weibo.page_image(), "The video preview image should be listed.") self.dr.get(weibo.miniurl()) self.assertRegex(self.dr.current_url(), '(passport.)?weibo.com/(login.php)?', "The Weibo mini-url should resolve to some Weibo page url.") else: # TODO: Do the global 360 share bit. pass