Example #1
0
 def confirm(self, button_txt: str = 'OK'):
     btn_confirm_modal = self.content.s(
         f"./descendant::button/span[text()='{button_txt}']/..")
     assert btn_confirm_modal.with_(Config(timeout=59)).wait_until(
         be.clickable)
     self.focus(btn_confirm_modal())
     btn_confirm_modal.click()
Example #2
0
def browser():
    options = webdriver.ChromeOptions()
    # options = webdriver.FirefoxOptions()

    options.set_capability("version", "84.0")
    options.set_capability("venv", "DEV")
    options.set_capability("vnc", True)
    options.set_capability("junit_report", "test_report")
    options.set_capability("report_uid", str(uuid4()))
    # options.set_capability("report_uid", "12345")
    options.set_capability("job_name", "DEMO")
    options.set_capability("galloper_url", "http://localhost")
    options.set_capability("galloper_token", os.environ.get('galloper_token'))
    options.set_capability('galloper_project_id', 1)
    options.set_capability('tz', 'Europe/Kiev')

    options.set_capability("jira_url", "http://localhost:8080")
    options.set_capability("jira_project", "DEMO")
    options.set_capability("jira_user", "")
    options.set_capability("jira_password", "123456")

    driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',
                              options=options)

    browser = Browser(
        Config(
            driver=driver,
            # driver=webdriver.Chrome(),
            base_url='https://ej2.syncfusion.com',
            timeout=4,
            window_width=1920,
            window_height=1080))
    yield browser
    browser.close_current_tab()
def remote_driver(t_browser, page_load_strategy=None):
    """ Remote driver """
    logging.debug('remote driver config start')
    remote_mapping = {
        'chrome': {
            'command_executor':
            'http://selenium__standalone-chrome:4444/wd/hub',
            'options': webdriver.ChromeOptions()
        },
        'firefox': {
            'command_executor':
            'http://selenium__standalone-firefox:4444/wd/hub',
            'options': webdriver.FirefoxOptions()
        }
    }
    if page_load_strategy:
        desired_capabilities = webdriver.DesiredCapabilities().CHROME
        desired_capabilities["pageLoadStrategy"] = "eager"

    driver = webdriver.Remote(
        command_executor=remote_mapping[t_browser]['command_executor'],
        options=remote_mapping[t_browser]['options'])
    driver.set_page_load_timeout(20)
    browser = Browser(
        Config(
            driver=driver,
            timeout=10,
            window_width=1500,
            window_height=1200,
        ))
    logging.debug('remote driver config finish')
    return browser
Example #4
0
 def register(self, login: str = None, password: str or int = None):
     browser.open(REGISTRATION_URL)
     self.__email_input.set_value(login or self.login)
     self.__password_input.should(be.visible).set_value(password
                                                        or self.password)
     self.__submit_button.click()
     customer = self.__set_registration_data()
     self.__register_submit_button.click()
     self.__register_submit_button.with_(Config(timeout=10)).should(
         be.not_.visible)
     return customer
Example #5
0
def test_changes_window_size_on_open_according_to_config(chrome_driver):
    browser = Browser(
        Config(
            driver=chrome_driver,
            window_width=640,
            window_height=480,
        )
    )

    browser.open(givenpage.EMPTY_PAGE_URL)

    assert browser.driver.get_window_size()['width'] == 640
    assert browser.driver.get_window_size()['height'] == 480
Example #6
0
def function_browser(request):
    if request.config.getoption('--headless'):
        chrome_driver = webdriver.Chrome(
            ChromeDriverManager().install(),
            options=headless_chrome_options(),
        )
    else:
        chrome_driver = webdriver.Chrome(
            service=Service(
                ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install()
            )
        )
    yield Browser(Config(driver=chrome_driver))
    chrome_driver.quit()
Example #7
0
def browser():
    browser = Browser(
        Config(
            driver=webdriver.Chrome(
                service=Service(
                    ChromeDriverManager(
                        chrome_type=ChromeType.GOOGLE
                    ).install()
                )
            )
        )
    )
    yield browser
    browser.quit()
Example #8
0
 def __set_registration_data(self):
     data = REGISTRATION_DATA
     first_name = data['first_name']
     last_name = data['last_name']
     self.__first_name_input.with_(Config(timeout=10)).should(
         be.visible).set_value(first_name)
     self.__last_name_input.set_value(last_name)
     self.__company_name_input.set_value(data['company_name'])
     set_select_option(
         browser.element(self.__country_select)(), data['country'])
     self.__city_input.set_value(data['city'])
     self.__phone_input.click().type(data['phone'])
     set_select_option(
         browser.element(self.__template_select)(), data['template'])
     return {'first_name': first_name, 'last_name': last_name}
def custom_driver(t_browser):
    """ Custom driver """
    logging.debug('custom driver config start')
    if t_browser == 'chrome':
        driver = webdriver.Chrome(
            executable_path=ChromeDriverManager().install(),
            options=headless_chrome_options())
    else:
        raise ValueError('t_browser does not set')
    driver.set_page_load_timeout(10)
    browser = Browser(
        Config(
            driver=driver,
            timeout=10,
            window_width=1366,
            window_height=1200,
        ))
    logging.debug('custom driver config finish')
    return browser
Example #10
0
def test_progress_bar_does_not_disappear_in_time(browser):
    """Test for page with progress bar that appears each time after click on a button.

    Test should use wait_until for progress bar to not disappear in timeout
        if not disappeared:
            pass the test
        else
            fail the test
    """
    show_dialog_btn = browser.element('.btn-primary')
    dialog = browser.element('.modal-backdrop.fade.in')
    browser.open(
        'https://demo.seleniumeasy.com/bootstrap-progress-bar-dialog-demo.html'
    )

    show_dialog_btn.click()
    dialog.should(be.visible)
    disappeared = dialog.with_(Config(timeout=1)).wait_until(be.not_.present)

    assert disappeared is False
Example #11
0
def web():
    def managed_driver() -> WebDriver:
        from selenium import webdriver

        def create_chrome():
            from selenium.webdriver.chrome.service import (
                Service as ChromeService, )

            return webdriver.Chrome(
                service=ChromeService(
                    ChromeDriverManager(
                        chrome_type=ChromeType.GOOGLE).install()),
                options=webdriver.ChromeOptions(),
            )

        # if _driver and Help(_driver).has_browser_still_alive():
        #     return _driver
        #
        # _driver = create_chrome()

        if (Settings.reset_driver and Settings.driver
                and WebHelper(Settings.driver).is_browser_still_alive()):
            Settings.driver.quit()
            Settings.reset_driver = False

        if (Settings.driver is None
                or not WebHelper(Settings.driver).is_browser_still_alive()):
            Settings.driver = create_chrome()

        return Settings.driver

    browser = Browser(Config(driver=managed_driver))

    yield browser

    Settings.driver.quit()
Example #12
0
def session_browser(chrome_driver):
    yield Browser(Config(driver=chrome_driver))
Example #13
0
from selene import Browser, Config
from selenium.webdriver import Firefox
"""
    Element
"""

browser = Browser(
    Config(driver=Firefox(),
           base_url='https://selenium.dunossauro.live',
           timeout=30))

browser.open('/aula_07')
elementos = browser.all('input')

elementos[0].type('rafael')
elementos[1].type('rafael@rafael')
elementos[2].type('rafael')
elementos[3].press_enter()
Example #14
0
 def wait_text_body(self, text, timeout=20, throw_exception=True):
     msg = self.content.s(f"./descendant::*[contains(text(), '{text}')]")
     result = msg.with_(Config(timeout=timeout)).wait_until(be.visible)
     if not result and throw_exception:
         raise ValueError("Mensagem não encontrada: " + text)
     return result
Example #15
0
 def wait_modal_title_presented(self, title=''):
     title_elem = self.content.s(
         "./descendant::*[@class='ant-modal-title']/*")
     assert title_elem.with_(Config(timeout=15)).wait_until(be.visible)
     if title != '':
         assert title_elem.text == title
from selene import Browser, Config
from selenium.webdriver import Firefox
from selene.support import by
from selene.support.conditions import not_, be, have

"""
    Validação
"""

browser = Browser(
    Config(
        driver=Firefox(),
        base_url='https://google.com',
    )
)

browser.open('')

browser.s(by.name('q')).should(be.blank).type('Live de python')

browser.s(by.name('q')).should(not_.blank).type('teste em python')

browser.s(by.name('q')).should(have.attribute('name').value('q'))

from selene import Browser, Config
from selenium.webdriver import Remote

base_url = 'http://selenium.dunossauro.live'

browser = Browser(
    Config(
        driver=Remote(desired_capabilities={'browserName': 'firefox'}),
        base_url=base_url,
    ))

browser.open('/caixinha')
Example #18
0
            options=driver_options,
        ))

        if settings.maximize_window:
            driver.maximize_window()
        else:
            driver.set_window_size(
                width=settings.window_width,
                height=settings.window_height,
            )

    # other driver configuration todos:
    # file upload when remote
    # - http://allselenium.info/file-upload-using-python-selenium-webdriver/
    #   - https://sqa.stackexchange.com/questions/12851/how-can-i-work-with-file-uploads-during-a-webdriver-test

    return driver


browser = Browser(
    Config(
        driver=lambda: _web_driver_from(project.settings),
        base_url=project.settings.base_url,
        timeout=project.settings.timeout,
    ))

web = browser
"""
just an alias to shared.browser
"""
Example #19
0
def browser(session_driver):
    yield Browser(Config(driver=session_driver))
Example #20
0
 def wait_modal_hidden(self, timeout=4):
     return self.wrapper.with_(Config(timeout=timeout)).wait_until(
         be.hidden)