Пример #1
0
def is_displayed(xpath):
    """Check element is visible"""
    Setup().driver.implicitly_wait(1)
    element = Setup().driver.find_elements_by_xpath(xpath)
    Setup().driver.implicitly_wait(config['common']['implicitly_wait'])

    return element
Пример #2
0
def url():
    """Get current url"""
    return Setup().driver.current_url
Пример #3
0
def find(xpath):
    """Find the element on page and return object of element"""
    wait(xpath)
    wait_clickable(xpath)
    return Setup().driver.find_element_by_xpath(xpath)
Пример #4
0
def get(url='', domain=None):
    """Go to url"""
    if not domain:
        domain = get_domain()
    Setup().driver.get('{}{}'.format(domain, url))
    return Setup().driver.current_url
Пример #5
0
# author: Oleg Sushchenko <*****@*****.**>

from init import Setup

driver = Setup().driver


def get_domain():
    """Get protocol from config and domain and return url
    """
    return driver.execute_script(
        'return location.protocol') + '//' + driver.execute_script(
            'return location.hostname') + '/'
Пример #6
0
# author: Oleg Sushchenko <*****@*****.**>

from selenium.webdriver.common.keys import Keys

from helpers.js_helper import get_domain
from helpers.waiting_helper import wait, wait_clickable
from init import Setup

config = Setup().config


def find(xpath):
    """Find the element on page and return object of element"""
    wait(xpath)
    wait_clickable(xpath)
    return Setup().driver.find_element_by_xpath(xpath)


def send(xpath, text):
    """Send text to field"""
    element = focus_to_element(find(xpath))
    element.clear()
    element.send_keys(text)
    return element


def push_enter_key(element):
    """Push the Enter key"""
    element.send_keys(Keys.RETURN)

Пример #7
0
def wait_clickable(xpath):
    """Wait for clickable"""
    wait = WebDriverWait(Setup().driver, 10)
    if EC.visibility_of((By.XPATH, xpath)):
        wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
Пример #8
0
def wait_ajax():
    """Awaiting ajax"""
    while Setup().driver.execute_script("return jQuery.active") != 0:
        time.sleep(0.5)
Пример #9
0
def wait(xpath, time=10):
    """Awaiting 10 sec till element become clickable"""
    wait = WebDriverWait(Setup().driver, time)
    wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
Пример #10
0
def get_domain():
    """Get protocol from config and domain and return url
    """
    return Setup().driver.execute_script(
        'return location.protocol') + '//' + Setup().driver.execute_script(
            'return location.hostname') + '/'
Пример #11
0
# author: Oleg Sushchenko <*****@*****.**>

from selenium.webdriver.common.keys import Keys

from helpers.js_helper import get_domain
from helpers.waiting_helper import wait, wait_clickable
from init import Setup

config = Setup().config
driver = Setup().driver


def find(xpath):
    """Find the element on page and return object of element"""
    wait(xpath)
    wait_clickable(xpath)
    return driver.find_element_by_xpath(xpath)


def send(xpath, text):
    """Send text to field"""
    element = focus_to_element(find(xpath))
    element.clear()
    element.send_keys(text)
    return element


def push_enter_key(element):
    """Push the Enter key"""
    element.send_keys(Keys.RETURN)