Ejemplo n.º 1
0
    def getElementByXPath(self,
                          xPathPath,
                          timeout=Config().cfShortTime,
                          isBug=False):
        element = None
        try:
            # First, set default time for wait an element
            AbstractPage.Browser().implicitly_wait(self.cfImplicitlyTimeWait)

            if timeout != 0:
                # Set new time value for wait an element
                AbstractPage.Browser().implicitly_wait(timeout)

            # Get element by xpath
            element = AbstractPage.Browser().find_element_by_xpath(xPathPath)

            return element

        except Exception:
            if isBug == False:
                # Close Browser and set test case is failed
                logWarning("Cannot get element with xpath: " + xPathPath)
                self.closeBrowser()
                self.fail()

        return None
Ejemplo n.º 2
0
 def doesElementExisted(self, element_xpath, timeout=Config().cfShortTime):
     try:
         WebDriverWait(AbstractPage.Browser,
                       timeout).until(lambda driver: self.getElementByXPath(
                           element_xpath, timeout, True))
         return True
     except Exception:
         return False
Ejemplo n.º 3
0
 def doesElementDisplay(self, element_xPath, timeout=Config().cfShortTime):
     try:
         element = self.getElementByXPath(element_xPath, timeout, True)
         status = element.is_displayed()
         return status
     except Exception, e:
         #             logInfo(str(e))
         return None