Exemple #1
0
 def __call__(self, driver):
     try:
         # TODO: Find a way to detect whether the website has fully loaded or not.
         playerframe = EC._find_element(driver,
                                        (By.ID, 'player-frame'))
         if not playerframe.value_of_css_property("z-index") == "1":
             return False
         # After watching the ad, the one element that gets opacity defines the outcome.
         fulfill = EC._find_element(driver, (By.ID, 'post-message'))
         unfill = EC._find_element(driver,
                                   (By.ID, 'no-fill-message'))
         maxed = EC._find_element(driver,
                                  (By.ID, 'max-view-message'))
         adblock = EC._find_element(
             driver, (By.ID, 'adblock-message-container'))
         # The element with the opacity == 1 is the one showing on top of the player.
         if fulfill.value_of_css_property("opacity") == "1":
             return True
         if unfill.value_of_css_property("opacity") == "1":
             return True
         if maxed.value_of_css_property("opacity") == "1":
             return True
         if adblock.value_of_css_property("opacity") == "1":
             return True
         return False
     except StaleElementReferenceException:
         return False
Exemple #2
0
 def __call__(self, driver):
     try:
         title_element = EC._find_element(driver, self.title_locator)
         logo_element = EC._find_element(driver, self.logo_locator)
         return True
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     for locator in self.locators:
         try:
             _find_element(driver, locator)
             return True
         except (NoSuchElementException, WebDriverException):
             pass
     else:
         return False
 def __call__(self, driver):
     element_href = EC._find_element(driver,
                                     self.locator).get_attribute('href')
     if element_href:
         return element_href
     else:
         return False
Exemple #5
0
 def __call__(self, driver):
     try:
         element = EC._find_element(driver, self.locator)
         element.value_of_css_property("opacity")
         return element.value_of_css_property("opacity") == 1
     except Exception:
         return False
Exemple #6
0
 def __call__(self, driver):
     try:
         element = _find_element(driver, self.locator)
         if element.text is not "":
             return element
     except StaleElementReferenceException:
         return False
Exemple #7
0
 def __call__(self, driver):
     try:
         element = EC._find_element(driver, self.locator)
         return element.text != '' and int(element.text) >= 1 and int(
             element.text) <= 2
     except StaleElementReferenceException:
         return False
Exemple #8
0
 def __call__(self, driver):
     try:
         element_text = EC._find_element(
             driver, self.locator).get_attribute('innerText')
         return self.pattern.search(element_text)
     except StaleElementReferenceException:
         return False
Exemple #9
0
 def __call__(self, driver):
     try:
         element_attribute = ec._find_element(
             driver, self.locator).get_attribute(self.attribute)
         return element_attribute == self.value
     except StaleElementReferenceException:
         return False
Exemple #10
0
 def __call__(self, driver):
     try:
         element_class = EC._find_element(
             driver, self.element).get_attribute(self.attribute)
         return element_class and self.value in element_class
     except StaleElementReferenceException:
         return False
Exemple #11
0
 def __call__(self, driver):
     try:
         element_text = EC._find_element(driver, self.locator).text
         return (element_text.startswith('Uh')
                 or element_text.startswith('Feedback'))
     except StaleElementReferenceException:
         return False
Exemple #12
0
 def __call__(self, driver):
     try:
         if isinstance(self.locator, WebElement):
             return _element_if_visible(self.locator)
         return _element_if_visible(_find_element(driver, self.locator))
     except StaleElementReferenceException:
         return False
Exemple #13
0
 def __wait_for_attribute_value(self, driver, locator, attribute, value):
     try:
         element_attribute = EC._find_element(
             driver, locator).get_attribute(attribute)
         return element_attribute == value
     except StaleElementReferenceException:
         return False
Exemple #14
0
 def __call__(self, driver):
     try:
         element_text = exp_cond._find_element(driver, self.locator).text.strip()
         print(element_text)
         return element_text != ""
     except exceptions.StaleElementReferenceException:
         return False
    def is_element_enabled(self, timeout, *by):
        try:
            if WebDriverWait(self.driver, timeout).until(lambda driver: EC._find_element(driver, by)).is_enabled():
                status = True
        except Exception:
            status = False

        return status
Exemple #16
0
 def __call__(self, driver):
     try:
         element_text = exp_cond._find_element(driver,
                                               self.locator).text.strip()
         print(element_text)
         return element_text != ""
     except exceptions.StaleElementReferenceException:
         return False
Exemple #17
0
 def __call__(self, driver):
     try:
         element = EC._find_element(driver, self.locator)
         element_text = element.text.strip()
         if element_text != "Checking...":
             return element
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     try:
         css_classes = EC._find_element(driver,
                                        self.locator).get_attribute(
             'class')
         return self.css_class in css_classes
     except StaleElementReferenceException:
         return False
Exemple #19
0
 def __call__(self, driver):
     try:
         element_attribute = EC._find_element(driver, selector).get_attribute(attribute)
         if self.pre_value is None:
             self.pre_value = element_attribute
         return element_attribute != self.pre_value
     except:
         return False
Exemple #20
0
 def __call__(self, driver):
     js = """var components = Ext.ComponentQuery.query('%s')
             return components.length && components[0].id""" % (
         self.locator)
     print js
     id = driver.execute_script(js)
     locator = By.CSS_SELECTOR, '#%s' % id
     return _element_if_visible(_find_element(driver, locator))
Exemple #21
0
 def __call__(self, driver):
     # return _find_element(driver, self.locator)
     try:
         # if isinstance(self.locator, WebElement):
         #     return _element_if_visible(self.locator)
         return _find_element(driver, self.locator)
     except:
         return False
 def __call__(self, driver):
     try:
         element = EC._find_element(driver, self.locator)
         if element.text.strip() != "":
             return element
         else:
             return False
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     try:
         element_text = EC._find_element(
             driver, self.locator).get_attribute("value")
         print(element_text)
         return len(element_text) > 0
     except Exception as e:
         print(e)
         return False
    def is_element_enabled(self, timeout, *by):
        try:
            if WebDriverWait(self.driver, timeout).until(
                    lambda driver: EC._find_element(driver, by)).is_enabled():
                status = True
        except Exception:
            status = False

        return status
Exemple #25
0
 def __call__(self, driver):
     try :
         element_text = expected_conditions._find_element(driver, self.locator).text
         for text in self.texts:
             if text in element_text:
                 return text
         return False
     except StaleElementReferenceException:
         return False
Exemple #26
0
 def __call__(self, driver):
     for locator in self.locators:
         try:
             element = EC._find_element(driver, locator)
             if self.text in element.text:
                 return element
         except StaleElementReferenceException:
             continue
     return False
Exemple #27
0
 def __call__(self, driver):
     try:
         src = EC._find_element(driver, self.locator).get_attribute('src')
         if src != "https://gre.etest.net.cn/resources/images/loading.gif":
             return True
         else:
             return False
     except:
         return False
Exemple #28
0
 def __call__(self, driver):
     try:
         el = EC._find_element(driver, self.locator)
         if not isinstance(el, bool) and el is not None:
             return self.text in (el.get_attribute("value")
                                  or el.get_attribute("text"))
         else:
             return False
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     try:
         element_text = _EC._find_element(
             driver, self.locator).get_attribute('href')
         if element_text:
             return self.text in element_text
         else:
             return False
     except:
         return False
    def __call__(self, driver):
        try:
            element_text = EC._find_element(driver, self.locator).text

            if len (element_text.strip ()) is not 0:
                return True
            else:
                return False
        except StaleElementReferenceException:
            return False
Exemple #31
0
 def __call__(self, driver):
     try:
         element_attribute = EC._find_element(
             driver, self.locator).get_attribute(self.attribute)
         if element_attribute:
             return self.value in element_attribute
         else:
             return False
     except StaleElementReferenceException:
         return False
 def is_element_enabled(self, *by):
     try:
         if WebDriverWait(self.browser, settings.FIND_ELEMENT_TIMEOUT).until(
                 lambda driver: EC._find_element(driver, by)).is_enabled():
             status = True
         else:
             status = False
     except Exception:
         status = False
     return status
Exemple #33
0
 def __call__(self, driver):
     try:
         element_text = expected_conditions._find_element(
             driver, self.locator).text
         for text in self.texts:
             if text in element_text:
                 return text
         return False
     except StaleElementReferenceException:
         return False
Exemple #34
0
 def _check_failed_to_assign_backend(self):
     el_gpu_not_available_locator = SeleniumLocator(By.CSS_SELECTOR, "body colab-dialog paper-dialog")
     try:
         el_gpu_not_available = EC._find_element(self.driver, el_gpu_not_available_locator)
         if el_gpu_not_available is not None:
             el_gpu_not_available_text = el_gpu_not_available.text
             if el_gpu_not_available_text is not None and \
                     el_gpu_not_available_text.find("Failed to assign a backend") >= 0:
                 raise BackendNotAvailableError()
     except selenium.common.exceptions.NoSuchElementException:
         pass
 def __call__(self, driver):
     try:
         element_text = EC._find_element(driver, self.locator).text.replace(" modified", '')\
                                                                     .replace(" Modified", '')\
                                                                     .replace(" Amended", '')\
                                                                     .replace(" amended", '')\
                                                                     .replace(" New", '') \
                                                                     .replace(" new", '')
         return element_text.startswith(self.text)
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     text = expected_conditions._find_element(driver, self.locator).text
     return text != self.before_text
Exemple #37
0
 def __call__(self, driver):
     try:
         element_text = EC._find_element(driver, self.locator).text
         return self.pattern.search(element_text)
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     try:
         element = EC._find_element(driver, self.locator)
         return element.value_of_css_property("display") == "none"
     except Exception:
         return False
Exemple #39
0
 def __call__(self, driver):
     try :
         element_text = EC._find_element(driver, self.locator).text.strip()
         return element_text != "0,00"
     except StaleElementReferenceException:
         return False
 def __call__(self, driver):
     try:
         element_text = _find_element(driver, self.locator).text
         return any([t in element_text for t in self.text])
     except StaleElementReferenceException:
         return False
Exemple #41
0
 def __call__(self, driver):
     try:
         element = expected_conditions._find_element(driver, self.locator)
         return self.check(element)
     except StaleElementReferenceException:
         return False