def selectDropdownListItemXpath(self, xpath, xpathItem): if AbstractPage.flag: try: self.getSettingPage.getElementByXPath(xpath).click() self.getSettingPage.getElementByXPath(xpathItem).click() except Exception, e: Log.logError(str(e))
def clickElementById(self, id): if AbstractPage.flag: try: element = self.getElementByID(id) element.click() except Exception, e: Log.logError(str(e))
def selectDropdownListItem(self, id, value): if AbstractPage.flag: try: select = Select(self.getElementByID(id)) select.select_by_visible_text(value) except Exception, e: Log.logError(str(e))
def clickElementByXPath(self, xpath): if AbstractPage.flag: try: element = self.getElementByXPath(xpath) element.click() except Exception, e: Log.logError(str(e))
def getLocationForElementById(self, id): if AbstractPage.flag: try: element = self.getElementByID(id) return element.location['x'], element.location['y'] except Exception, e: Log.logError(str(e))
def getLocationForElementXpath(self, xPath): if AbstractPage.flag: try: element = self.getElementByXPath(xPath) return element.location['x'], element.location['y'] except Exception, e: Log.logError(str(e))
def getNameOfPicture(self): if AbstractPage.flag: try: return self.getAttributeByXPath(self.img_myProfile_xpath, "title") except Exception, e: Log.logError(str(e))
def isScoreExisted_profilePage(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.img_score_xpath): Log.logInfo("Control Score is existed!") return True else: Log.logInfo("Control Score is not existed!") return False
def mouseMoveToElementById(self, elementID): if AbstractPage.flag: try: element = self.getElementByID(elementID) hov = ActionChains(AbstractPage.Browser()).move_to_element(element) hov.perform() except Exception, e: Log.logError(str(e))
def checkControlExistedByXpath(self,element_xpath, timeout = 60): if AbstractPage.flag: try: WebDriverWait(AbstractPage.Browser, timeout).until(lambda driver: AbstractPage.Browser().find_element_by_xpath(element_xpath)) return True except Exception, e: Log.logError(str(e)) return False
def isPopupAddFriendTwitterDisplay(self): if AbstractPage.flag: if self.checkControlExistedById(self.btn_tweet_xpath): Log.logInfo("Popup Add Friend Twitter displays!") return True else: Log.logInfo("Popup Add Friend Twitter is not displayed!") return False
def isPopupDisplayed(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.img_closePopup_xpath): Log.logInfo("Popup displayed!") return True else: Log.logInfo("Popup is not displayed!") return False
def isProfilePageExisted(self): if AbstractPage.flag: if self.isScoreExisted()and self.isProfilePictureExisted(): Log.logInfo("Profile Page is existed!") return True else: Log.logInfo("Profile Page is not existed!") return False
def isScoreExisted(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.img_score_xpath): Log.logInfo("Score picture is existed") return True else: Log.logInfo("Score picture is not existed") return False
def getTextById(self, id): if AbstractPage.flag: try: element = self.getElementByID(id) return element.text except Exception, e: Log.logError(str(e)) AbstractPage.flag = False
def getTextByXPath(self, xpath): if AbstractPage.flag: try: element = self.getElementByXPath(xpath) return element.text except Exception, e: Log.logError(str(e)) AbstractPage.flag = False
def getAttributeById(self, id, attributeName): if AbstractPage.flag: try: element = self.getElementByID(id) return element.get_attribute(attributeName) except Exception, e: Log.logError(str(e)) AbstractPage.flag = False
def isSeemoreLinkExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.link_seeMoreTopic_xpath): Log.logInfo("See more link is existed!") return True else: Log.logInfo("See more link is not existed!") return False
def sendKeyById(self, id, value): if AbstractPage.flag: try: element = self.getElementByID(id) element.clear() element.send_keys(value) except Exception, e: Log.logError(str(e))
def isProfilePictureExisted(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.img_myProfile_xpath): Log.logInfo("Profile's picture is existed!") return True else: Log.logInfo("Profile's picture is not existed!") return False
def sendKeyByxPath(self, xPath, value): if AbstractPage.flag: try: element = self.getElementByXPath(xPath) element.clear() element.send_keys(value) except Exception, e: Log.logError(str(e))
def isLogoutPageSuccessfully(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.btn_twitter_xpath): Log.logInfo("Logout facebook completely") return True else: Log.logInfo("Logout facebook imcompletely") return False
def closeBrowser(): try: AbstractPage.Browser().quit() AbstractPage.browser = None AbstractPage.flag = True Log.logInfo("Close browser") except Exception, e: Log.logError(str(e))
def getElementByXPath(self, xPath, timeout = 30): if AbstractPage.flag: try: WebDriverWait(AbstractPage.Browser, timeout).until(lambda driver: AbstractPage.Browser().find_element_by_xpath(xPath)) return AbstractPage.Browser().find_element_by_xpath(xPath) except Exception, e: Log.logError(str(e)) AbstractPage.flag = False
def isHomePageKloutExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.frm_score_network_pic_xpath): Log.logInfo("Klout Home Page is existed!") return True else: Log.logInfo("Klout Home Page is not existed!") return False
def isNetworkStatsFacebookExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.lbl_networkStatsFacebook_xpath): Log.logInfo("Network stats Facebook is existed!") return True else: Log.logInfo("Network stats Facebook is not existed!") return False
def is90DayScoreHistoryExist(self): if AbstractPage.flag: if self.checkControlExistedById(self.chart_90DayScoreHistory_ID): Log.logInfo("90 day score history is existed!") return True else: Log.logInfo("90 day score history is not existed!") return False
def isDeltaQuarterExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.lb_deltaQuarterValue_xpath) and self.checkControlExistedByXpath(self.lb_deltaQuarterTitle_xpath): Log.logInfo("Delta Quarter is existed!") return True else: Log.logInfo("Delta Quarter is not existed!") return False
def isPopupDisplayed(self): if AbstractPage.flag: if self.checkControlExistedById(self.pw_confirm_dialog_id): Log.logInfo("Popup displayed!") return True else: Log.logInfo("Popup is not displayed!") return False
def isNetworkStatsGooglePlusExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.lbl_networkStatsGoogleplus_xpath): Log.logInfo("Network stats google plus is existed!") return True else: Log.logInfo("Network stats google plus is not existed!") return False
def isPopupAddFacebookFriendDisplay(self): if AbstractPage.flag: if self.checkControlExistedById(self.pw_inviteFacebookFriend_id): Log.logInfo("Popup Add Facebook Friend displays!") return True else: Log.logInfo("Popup Add Facebook Friend is not displays!") return False
def isTwitterListExisted(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.pl_TWFriend_xpath): Log.logInfo("Twitter list element existed!") return True else: Log.logInfo("Twitter list element is not existed!") return False
def isProfilePageExisted(self): if AbstractPage.flag: if self.isScoreExisted() and self.isProfilePictureExisted(): Log.logInfo("Profile Page is existed!") return True else: Log.logInfo("Profile Page is not existed!") return False
def isNetworkUsedExist(self): if AbstractPage.flag: if self.checkControlExistedById(self.graph_networksUsed_ID): Log.logInfo("Network used graph is existed!") return True else: Log.logInfo("Network used graph is not existed!") return False
def isLoginPageKloutExist(self): if AbstractPage.flag: if self.checkControlExistedByXpath(self.btn_facebook_xpath): Log.logInfo("Login Page Klout Existed") return True else: Log.logInfo("Login Page Klout is not existed") return False
def isAllFriendCheckboxChecked(self): if AbstractPage.flag: ischecked = self.getAttributeByXPath(self.chb_selectAllFriend_xpath, "checked") if(ischecked == "true"): Log.logInfo("All Friend Checkbox is checked") return True else: Log.logInfo("All Friend Checkbox is not checked") return False