def getTopSiteText(self, siteElem): try: elem = self.getElement("topSites", "text", siteElem, timeout=1) return elem.text except Exception as e: self.log(e) FreshTabFailure("Error getting Text of the TopSite Element.")
def quickClearHistory(self): try: self.get3DotButton().click() self.getClearHistoryButton().click() self.getClearHistoryAcceptButton().click() except Exception as e: self.log(e) raise FreshTabFailure( "Error Clearing History from Fresh Tab :: History Panel")
def expandCollapseNews(self): try: self.clickElemCenter(self.getElement('moreNews', timeout=2)) except: try: self.clickElemCenter(self.getElement('lessNews', timeout=2)) except: raise FreshTabFailure( "News Section cannot be Expanded or Collapsed.") self.sleep(1)
def getAllTopSites(self, topSitesSection=None): if topSitesSection == None: topSitesSection = self.getTopSitesSection() try: assert topSitesSection != None return self.getElements("topSites", "site", topSitesSection, timeout=3) except Exception as e: self.log(e) FreshTabFailure("Error in getting Top Sites.")
def getTopSiteDeleteElem(self, topSiteElem): try: if self.isPlatform("ios"): return self.getElement("topSites", "delete", topSiteElem, timeout=1) else: return self.getButtonInMenu("delete", isPopup=True) except Exception as e: self.log(e) raise FreshTabFailure("Top Site Delete button cannot be found.")
def getContinueToWebsiteButton(self): try: return self.getElement("homeScreenOnboarding") except: try: self.getStopLoadingButton().click() return self.getElement("homeScreenOnboarding", timeout=3) except Exception as e: self.log(e) try: self.get3DotButton().click() self.getStopLoadingButton().click() return self.getElement("homeScreenOnboarding", timeout=3) except Exception as e: self.log(e) raise FreshTabFailure( "Home Screen Onboarding Popup did not Load within 10 seconds." )
def isNewsExpandedOrCollapsed(self, newsCount=None): if newsCount == None: if self.isPlatform("android"): newsCount = self.getNewsCount() return "expanded" if newsCount > self.getDefaultNewsCount( ) else "collapsed" elif self.isPlatform("ios"): try: self.getElement('moreNews', timeout=2) return "collapsed" except: try: self.getElement('lessNews', timeout=3) return "expanded" except: raise FreshTabFailure( "News Section either cannot be found or cannot be Expanded or Collapsed." ) else: return "expanded" if newsCount > self.getDefaultNewsCount( ) else "collapsed"
def getNewsSection(self): try: return self.getElement("newsSection") except: raise FreshTabFailure( "News Section did not Load within 10 seconds.")