def wait_for_element_CSS(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be displayed. The Element is located
    using its CSS_SELECTOR"""
    try:
        WebDriverWait(driver, time).until(lambda s: s.find_element(By.CSS_SELECTOR, locator).is_displayed())
    except NoSuchElementException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate required CSS element within requirement timeframe', 'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate required CSS element within requirement timeframe'
        email_module.wait_error_mail('CSS SELECTOR', locator, 'NoSuchElementException')
        return False
def wait_for_text_to_be_present(driver, locator, text, time=30):
    """Function is used to wait for the given text to be present in the given located element"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.text_to_be_present_in_element((By.XPATH, locator), text))
    except NoSuchElementException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate given text and/or element', 'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate given text and/or element'
        email_module.wait_error_mail('Text Present in Element', locator, 'NoSuchElementException')
        return False
示例#3
0
def wait_for_element_ID(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be displayed. The Element is located
    using its ID"""
    try:
        WebDriverWait(driver, time).until(
            lambda s: s.find_element(By.ID, locator).is_displayed())
    except NoSuchElementException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate required ID element within requirement timeframe',
            'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate required ID element within requirement timeframe'
        email_module.wait_error_mail('ID', locator, 'NoSuchElementException')
        return False
示例#4
0
def wait_for_text_to_be_present(driver, locator, text, time=30):
    """Function is used to wait for the given text to be present in the given located element"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.text_to_be_present_in_element((By.XPATH, locator), text))
    except NoSuchElementException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate given text and/or element',
            'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate given text and/or element'
        email_module.wait_error_mail('Text Present in Element', locator,
                                     'NoSuchElementException')
        return False
def wait_for_element_XPATH(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be displayed. The Element is located
    using its XPATH"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.visibility_of_element_located((By.XPATH, locator)))
        #WebDriverWait(driver, time).until(lambda s: s.find_element(By.XPATH, locator).is_displayed())
        return True
    except NoSuchElementException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate required XPATH element within requirement timeframe', 'FAILED')
        print 'ERROR - NO SUCH ELEMENT - Failed to locate required XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'NoSuchElementException')
        return False
    except TimeoutException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate required XPATH element within requirement timeframe', 'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate required XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'TimeoutException')
        return False
示例#6
0
def wait_to_be_clickable_XPATH(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be clickable. The Element is located
    using its XPATH"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.element_to_be_clickable((By.XPATH, locator)))
        return True
    except NoSuchElementException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element',
            'FAILED')
        print 'ERROR - NO SUCH ELEMENT - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator,
                                     'NoSuchElementException')
        return False
    except ElementNotSelectableException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element',
            'FAILED')
        print 'ERROR - ELEMENT NOT CLICKABLE - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator,
                                     'ElementNotSelectableException')
        return False
    except TimeoutException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element',
            'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'TimeoutException')
        return False
示例#7
0
def wait_for_element_XPATH(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be displayed. The Element is located
    using its XPATH"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.visibility_of_element_located((By.XPATH, locator)))
        #WebDriverWait(driver, time).until(lambda s: s.find_element(By.XPATH, locator).is_displayed())
        return True
    except NoSuchElementException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate required XPATH element within requirement timeframe',
            'FAILED')
        print 'ERROR - NO SUCH ELEMENT - Failed to locate required XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator,
                                     'NoSuchElementException')
        return False
    except TimeoutException:
        log_to_file(
            'Test_VFL_Module:TIMEOUT:Failed to locate required XPATH element within requirement timeframe',
            'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate required XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'TimeoutException')
        return False
def wait_to_be_clickable_XPATH(driver, locator, time=30):
    """Function used to Explicitly Wait for an element to be clickable. The Element is located
    using its XPATH"""
    wait = WebDriverWait(driver, time)
    try:
        wait.until(EC.element_to_be_clickable((By.XPATH, locator)))
        return True
    except NoSuchElementException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element', 'FAILED')
        print 'ERROR - NO SUCH ELEMENT - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'NoSuchElementException')
        return False
    except ElementNotSelectableException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element', 'FAILED')
        print 'ERROR - ELEMENT NOT CLICKABLE - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'ElementNotSelectableException')
        return False
    except TimeoutException:
        log_to_file('Test_VFL_Module:TIMEOUT:Failed to locate clickable XPATH element', 'FAILED')
        print 'ERROR - TIMEOUT - Failed to locate clickable XPATH element within requirement timeframe'
        email_module.wait_error_mail('XPATH', locator, 'TimeoutException')
        return False