Esempio n. 1
0
 def __call__(self, driver):
     try:
         driver.switch_to.default_content()
         return True
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 2
0
 def __call__(self, driver):
     try:
         driver.forward()
         return True
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
 def __call__(self, driver):
     try:
         driver.maximize_window()
         time.sleep(1)
         return True
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 4
0
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         driver.switch_to.frame(self.name)
         return True
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 5
0
 def __call__(self, driver):
     try:
         javascript = 'return window.location.href'
         url = driver.execute_script(javascript)
         return url
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 6
0
 def __call__(self, driver):
     try:
         element = driver.find_element(self.locator_type,
                                       self.locator_value)
         return element.is_displayed()
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 7
0
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         element = driver.find_element(self.locator_type, self.locator_value)
         driver.switch_to.frame(element)
         return True
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 8
0
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         element = driver.find_element(self.locator_type,
                                       self.locator_value)
         element_text = element.text
         return element_text.strip()
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 9
0
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         element = driver.find_element(self.locator_type,
                                       self.locator_value)
         if element.is_selected():
             element.click()
         return not element.is_selected()
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
 def create_browser():
     """Creates a chrome instance and returns the driver object"""
     logger.debug("Creating chrome instance")
     try:
         system = OperatingSystem.get_operating_system()
         if system == OperatingSystem.Windows:
             driver = DriverFactory.__create_local_windows()
         elif system == OperatingSystem.Linux:
             driver = DriverFactory.__create_local_linux()
         elif system == OperatingSystem.Mac:
             driver = DriverFactory.__create_local_mac()
         else:
             raise Exception("Unsupported browser location and operating system")
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
         driver.set_script_timeout(SeleniumSettings.get_script_wait())
         if system != OperatingSystem.Linux:
             driver.fullscreen_window()
             driver.maximize_window()
         return driver
     except Exception as e:
         logger.error("Error creating chrome instance: %s" % e)
         raise
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         handles = driver.window_handles
         for handle in handles:
             if handle == self.default_handle:
                 driver.switch_to.window(handle)
                 return True
         # above actions dont invoke an implicit wait
         time.sleep(1)
         return False
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
Esempio n. 12
0
 def __call__(self, driver):
     try:
         driver.implicitly_wait(1)
         element = driver.find_element(self.locator_type,
                                       self.locator_value)
         element.clear()
         element.send_keys(self.text)
         actual_text = element.text
         actual_value = element.get_attribute('value')
         if actual_text is None:
             actual_text = ''
         if actual_value is None:
             actual_value = ''
         return actual_text.strip() == self.text or actual_value.strip(
         ) == self.text
     except Exception:
         return False
     finally:
         driver.implicitly_wait(SeleniumSettings.get_implicit_wait())
def set_page_load_wait(seconds):
    """Sets the wait time for a page load"""
    SeleniumSettings.set_page_load_wait(float(seconds))
    logger.info("Set page load wait to %s seconds" % str(seconds))
def set_selenium_script_wait(seconds):
    """Sets the selenium javascript wait"""
    SeleniumSettings.set_script_wait(float(seconds))
    logger.info("Set script wait to %s seconds" % str(seconds))
def set_selenium_explicit_wait(seconds):
    """Sets the selenium explicit wait"""
    SeleniumSettings.set_explicit_wait(float(seconds))
    logger.info("Set explicit wait to %s seconds" % str(seconds))