Example #1
0
 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))
Example #2
0
 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))
Example #3
0
 def mergeUserTwitterWithFacebook(self, usernameMerged, passwordMerged):
     if AbstractPage.flag:
         try:
             if(self.checkControlExistedById(self.link_unlinkFacebook_id, 5)==False):
                 if self.checkControlExistedByXpath(self.btn_connectNowFb_xpath) == True:
                     # Click connect now to facebook
                     self.facebookLoginPage = self.connectNowFacebook()
                     
                     # Login facebook                             
                     self.facebookLoginPage.login(usernameMerged, passwordMerged)
                     
                     # Click on Allow button if show message warning
                     if self.facebookLoginPage.checkControlExistedByXpath(self.facebookLoginPage.btn_allow_xpath,timeout=5) == True:
                         self.facebookLoginPage.clickElementByXPath(self.facebookLoginPage.btn_allow_xpath)
                                               
                     # Close dialog
                     self.closePopup()                            
                     
                     # Click on Merge Account button
                     if self.checkControlExistedByXpath(self.btn_mergeAccount_xpath,timeout=5) == True:
                         self.clickElementByXPath(self.btn_mergeAccount_xpath)
             else:
                 Log.logInfo("Account merged.")
         except Exception, e:
             Log.logError(str(e))
             Log.logInfo("Account is not merged.")
Example #4
0
 def getNameOfPicture(self):
     if AbstractPage.flag:
         try:                                                                                
             return self.getAttributeByXPath(self.img_myProfile_xpath, "title")
             
         except Exception, e:
             Log.logError(str(e))
Example #5
0
 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))
Example #6
0
 def clickElementById(self, id):
     if AbstractPage.flag:
         try:
             element = self.getElementByID(id)
             element.click()
         except Exception, e:
             Log.logError(str(e))
Example #7
0
 def clickElementByXPath(self, xpath):
     if AbstractPage.flag:
         try:
             element = self.getElementByXPath(xpath)
             element.click()
         except Exception, e:
             Log.logError(str(e))
Example #8
0
 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))
Example #9
0
 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))
Example #10
0
 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))
Example #11
0
 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
Example #12
0
 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
Example #13
0
 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
Example #14
0
 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))
Example #15
0
    def getNameOfPicture(self):
        if AbstractPage.flag:
            try:
                return self.getAttributeByXPath(self.img_myProfile_xpath,
                                                "title")

            except Exception, e:
                Log.logError(str(e))
Example #16
0
 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
Example #17
0
 def closeBrowser():
     try:
         AbstractPage.Browser().quit()
         AbstractPage.browser = None
         AbstractPage.flag = True
         Log.logInfo("Close browser")
     except Exception, e:
         Log.logError(str(e))
Example #18
0
 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
Example #19
0
 def selectRadioButtonById(self, id):
     if AbstractPage.flag:
         try:
             element = self.getElementByID(id)
             status = self.getAttributeById(id, "checked")
             if status == None:
                 element.click()
         except Exception, e:
             Log.logError(str(e))
Example #20
0
 def getListNameFromPopUp(self):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().switch_to_alert()
             txt_shareNewPopup = self.getTextByXPath(self.txt_shareNewPopup_xpath)
             txt_listname = str(txt_shareNewPopup).split('"')
             return txt_listname[1]
         except Exception, e:
             Log.logError(str(e))
             return str(e)
Example #21
0
    def getAccountName(self):
        if AbstractPage.flag:
            try:
                # Get first name and last name
                self.FirstName = self.getTextByXPath(self.lbl_firstName_xpath)
                self.LastName = self.getTextByXPath(self.lbl_lastName_xpath)

                return self.FirstName, self.LastName
            except Exception, e:
                Log.logError(str(e))
Example #22
0
 def getAccountName(self):
     if AbstractPage.flag:
         try:
             # Get first name and last name
             self.FirstName = self.getTextByXPath(self.lbl_firstName_xpath)                
             self.LastName = self.getTextByXPath(self.lbl_lastName_xpath)
             
             return self.FirstName, self.LastName
         except Exception, e:
             Log.logError(str(e))
Example #23
0
 def getListNameFromPopUp(self):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().switch_to_alert()
             txt_shareNewPopup = self.getTextByXPath(
                 self.txt_shareNewPopup_xpath)
             txt_listname = str(txt_shareNewPopup).split('"')
             return txt_listname[1]
         except Exception, e:
             Log.logError(str(e))
             return str(e)
Example #24
0
 def Browser(cls):
     if cls.browser == None:
         # open browser
         try:
             if AbstractPage.browser == None:
                 AbstractPage.browser = Browser.initBrowser()
             Log.logInfo("Open browser successfully")
         except Exception, e:
             Log.logError(str(e))
             Log.logError("Open browser unsuccessfully")
             AbstractPage.flag = False
Example #25
0
    def openAccountSettingPage(self):
        if AbstractPage.flag:

            # click dropdown menu
            self.clickElementById(self.btn_dropMenu_id)

            # Open Account Setting page
            self.clickElementByXPath(self.link_accountSetting_xpath)

            Log.logError("Open account setting successfully")
            return AccountSettingPageFB()
Example #26
0
 def openAccountSettingPage(self):
     if AbstractPage.flag:
       
         # click dropdown menu
         self.clickElementById(self.btn_dropMenu_id)
         
         # Open Account Setting page
         self.clickElementByXPath(self.link_accountSetting_xpath)
                     
         Log.logError("Open account setting successfully")                      
         return AccountSettingPageFB()
Example #27
0
 def navigateToWeb(url):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().get(url)
             AbstractPage.Browser().implicitly_wait(60)
             Log.logInfo("Navigate to %s successfully" % url)
             return AbstractPage.Browser()
         except Exception, e:
             AbstractPage.flag = False
             Log.logError(str(e))
             Log.logError("Navigate to %s unsuccessfully" % url)
Example #28
0
 def switchToPopUpWindow(self):
     if AbstractPage.flag:
         try:
             # get current window
             parentWindow = AbstractPage.browser.current_window_handle
             handles = AbstractPage.browser.window_handles 
             handles.remove(parentWindow)
             # handle pop up window
             AbstractPage.browser.switch_to_window(handles.pop())
         except Exception, e:
             Log.logError(str(e))
             AbstractPage.flag = False
Example #29
0
 def closePopup(self):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().switch_to_alert()
             # Click on 'x' link
             self.clickElementByXPath(self.btn_closeConnectPageDialog_xpath)                               
             
             Log.logInfo("The pop up closed successfully")
             return SettingPageKlout()
         except Exception, e:
             Log.logError(str(e))
             Log.logError("The pop up doesnot close successfully")
Example #30
0
 def isProfileOfSelectedUserIsReturned(self, username):
     if AbstractPage.flag:
         try:
             fullName = self.getTextByXPath(self.lbl_firstName_xpath)+self.getTextByXPath(self.lbl_lastName_xpath)
             if str(fullName).__contains__(username)== True:
                 Log.logInfo("Profile of selected user is returned.")
                 return True
             else:
                 Log.logInfo("Profile of selected user is not returned.")
                 return False
         except Exception, e:
             Log.logError(str(e))
             return False
Example #31
0
 def isListNameOnPopup(self, listName):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().switch_to_alert()
             txt_shareNewPopup = self.getTextByXPath(self.txt_shareNewPopup_xpath)
             if str(txt_shareNewPopup).__contains__(listName) == True:
                 Log.logInfo("List name is on the pop up.")
                 return True
             else:
                 Log.logInfo("List name is not on the pop up.")
                 return False
         except Exception, e:
             Log.logError(str(e))
             return False
Example #32
0
 def isListNameOnPopup(self, listName):
     if AbstractPage.flag:
         try:
             AbstractPage.Browser().switch_to_alert()
             txt_shareNewPopup = self.getTextByXPath(
                 self.txt_shareNewPopup_xpath)
             if str(txt_shareNewPopup).__contains__(listName) == True:
                 Log.logInfo("List name is on the pop up.")
                 return True
             else:
                 Log.logInfo("List name is not on the pop up.")
                 return False
         except Exception, e:
             Log.logError(str(e))
             return False
Example #33
0
 def isProfileOfSelectedUserIsReturned(self, username):
     if AbstractPage.flag:
         try:
             fullName = self.getTextByXPath(
                 self.lbl_firstName_xpath) + self.getTextByXPath(
                     self.lbl_lastName_xpath)
             if str(fullName).__contains__(username) == True:
                 Log.logInfo("Profile of selected user is returned.")
                 return True
             else:
                 Log.logInfo("Profile of selected user is not returned.")
                 return False
         except Exception, e:
             Log.logError(str(e))
             return False
Example #34
0
 def checkControlStatus(self, id, status):
     if AbstractPage.flag:
         try:
             controlStatus = self.getAttributeById(id, status)
             if controlStatus != None and status == "disabled":
                 Log.logInfo("Control status is disabled")
                 return True
             elif controlStatus == None and status == "enabled":
                 Log.logInfo("Control status is enabled")
                 return True
             else:
                 Log.logInfo("Cannot find control")
                 return False        
         except Exception, e:
             Log.logError(str(e))
             return False
Example #35
0
 def logoutKlout():
     if AbstractPage.flag:
         try:
             # Log out if the page is the home (already logged in) then log out before logging in
             page = AbstractPage()
             if page.checkControlExistedById(page.btn_dropdownMenu_id):
                 # Select Log out menu item
                 # wait for dropdown menu displayed successful
                 time.sleep(1)
                 page.mouseMoveToElementById(page.btn_dropdownMenu_id)
                 # wait for dropdown menu displayed successful
                 time.sleep(1)
                 page.mouseMoveToElementById(page.btn_home_id)
                 page.mouseMoveToElementById(page.btn_dropdownMenu_id)
                 page.clickElementByXPath(page.link_logout_xpath)
             page = None
         except Exception, e:
             Log.logError(str(e))
Example #36
0
 def logoutFacebook():
     if AbstractPage.flag:
         try:
             # Log out if the page is the home (already logged in) then log out before logging in
             page = AbstractPage()
             if page.checkControlExistedById(page.btn_homeFacebook_id):
             # Click dropdown menu
                 page.clickElementById(page.btn_dropMenuFacebook_id)
                 # wait for dropdown menu displayed successful
                 time.sleep(2)
                 
                 # Click Logout
                 page.clickElementByXPath(page.link_logoutFacebook_xpath)
                 time.sleep(2)
                 
             page = None
         except Exception, e:
             Log.logError(str(e))
Example #37
0
 def logoutTwitter():
     if AbstractPage.flag:
         try:
             # Log out if the page is the home (already logged in) then log out before logging in
             page = AbstractPage()
             if page.checkControlExistedById(page.btn_dropMenuTwitter_id):
             # Click dropdown menu
                 time.sleep(5)
                 page.clickElementById(page.btn_dropMenuTwitter_id)
                 time.sleep(2)
                 
                 # Click Logout
                 page.clickElementByXPath(page.link_logoutTW_xpath)
                 time.sleep(2)
                 
             page = None
         except Exception, e:
             Log.logError(str(e))
Example #38
0
 def logoutTwitterWhenLoggedIn(self):        
     if AbstractPage.flag:
         try:
             element01 = self.getElementByXPath(self.btn_dropMenuTW_xpath)
             element02 = self.getElementByXPath(self.btn_logoutTW_xpath)
             
             # Use ActionChains class to set click action for elements
             builder = ActionChains(AbstractPage.browser); 
             builder.click(element01);
             builder.click(element02);  
             
             # Execute javascript to click on element on Twitter Home page
             # Parameters:
             # first argument - The JavaScript to execute
             # second argument - The arguments to the script. May be empty
             AbstractPage().browser.execute_script("arguments[0].click();", element01)
             AbstractPage().browser.execute_script("arguments[0].click();", element02)                               
             
         except Exception, e:
                 Log.logError(str(e))
                 Log.logError("Log out unsuccessfully")                    
                 AbstractPage.flag = False