Example #1
0
    def open(self):
        # костыль, отключает пераметр base_url из defaults.ini, используем абсолютный url: https://timepad.ru
        from selene import config
        config.base_url = ""

        open_url('https://timepad.ru/')
        return self
Example #2
0
def test_can_make_screenshot_with_custom_name():
    open_url(start_page)
    actual = take_screenshot(filename="custom")

    expected = os.path.join(get_default_screenshot_folder(), 'custom.png')
    assert expected == actual
    assert os.path.exists(actual)
def test_can_hold_autocreated_browser_open():
    config.hold_browser_open = True
    open_url(start_page)
    webdriver = driver()
    factory.kill_all_started_drivers()
    assert factory.is_driver_still_open(webdriver)
    webdriver.quit()
Example #4
0
    def open(self):
        # костыль, отключает пераметр base_url из defaults.ini, используем абсолютный url: https://timepad.ru
        from selene import config
        config.base_url = ""

        open_url('http://192.168.10.151/auth/identity/account/login')
        return self
def collect_repos():
    logging.info("start collecting repo urls ...")
    urls = {}

    page.projects_button.should(be.clickable).click()
    projects_url = browser.driver().current_url

    time.sleep(10)
    for project in page.projects:

        # form project dir name
        project_dir = project.get_attribute("href").split("/")[-1].lower()
        urls[project_dir] = []

        project.click()

        repos_url = browser.driver().current_url

        time.sleep(10)
        for repo in page.repos:
            repo.click()
            page.clone_button.click()

            url = page.actual_href_element.should(
                be.visible).get_attribute("value")
            urls[project_dir].append(url)
            logging.info(f"repo url: '{url}' has been collected ...")

            browser.open_url(repos_url)
        browser.open_url(projects_url)

    logging.info("repo collecting has been finished.")
    return urls
Example #6
0
def test_filter_tasks():
    config.browser_name = 'chrome'

    browser.open_url('https://todomvc4tasj.herokuapp.com')
    clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
    browser.wait_to(have.js_returned_true(clear_completed_js_loaded),
                    timeout=config.timeout * 3)

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()
    ss('#todo-list li').should(have.exact_texts('a', 'b', 'c'))

    ss('#todo-list li').element_by(
        have.exact_text('b')).element('.toggle').click()
    s(by.link_text('Active')).click()
    ss('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'c'))

    s(by.link_text('Completed')).click()
    ss('#todo-list li').filtered_by(be.visible).should(have.exact_texts('b'))

    s(by.link_text('All')).click()
    ss('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'b', 'c'))
Example #7
0
def test_otus():
    browser.open_url('https://otus.ru/')
    # print(browser.title())  # 'Онлайн курсы для профессионалов'
    browser.element(by.text('Отзывы')).click()
    el = browser.elements(by.css('.review-tile')).first().text
    print(el)
    browser.should(have.text('Selenium'))
Example #8
0
def test_can_make_screenshot_with_default_name():
    open_url(start_page)
    actual = take_screenshot()

    expected = os.path.join(get_default_screenshot_folder(),
                            'screen_{id}.png'.format(id=get_screen_id()))
    assert expected == actual
    assert os.path.exists(actual)
Example #9
0
def test_can_get_latest_screenshot_path():
    config.reports_folder = os.path.dirname(os.path.abspath(__file__)) + '/../../build/screenshots'
    open_url(start_page)
    with pytest.raises(TimeoutException):
        s("#s").should_be(visible)

    picture = latest_screenshot()
    assert os.path.exists(picture)
Example #10
0
def test_can_make_screenshot_automatically():
    open_url(start_page)
    config.timeout = 0.1
    with pytest.raises(TimeoutException) as ex:
        s("#selene_link").should_have(exact_text("Selen site"))
    expected = os.path.join(get_default_screenshot_folder(),
                            'screen_{id}.png'.format(id=get_screen_id()))
    assert os.path.exists(expected)
def test_add_tasks():
    browser.open_url(todomvc_url)
    browser.should(have.js_returned_true(is_TodoMVC_loaded))

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()

    ss("#todo-list>li").should(have.texts('a', 'b', 'c'))
Example #12
0
    def test_send_new_jobs_to_slack(self, wd, keyword):
        config.base_url = 'https://www.freelancer.com/jobs/regions/'

        open_url("")
        jobs_el = FreelancerSearchPage.search_job(keyword)
        jobs_result = FreelancerSearchPage.get_jobs_from_page(jobs_el, keyword)
        Utils.send_results_to_slack(channel='job-freelancercom', results=jobs_result, file_name=CSV_FILE_NAME)
        Utils.write_csv(jobs_result, file_name=CSV_FILE_NAME)
        Utils.write_xlsx(jobs_result, file_name=XLSX_FILE_NAME)
Example #13
0
    def test_send_new_jobs_to_slack(self, wd, keyword):
        config.base_url = 'https://www.upwork.com/o/jobs/browse/'
        open_url('?q={_keyword}'.format(_keyword=keyword))

        jobs_result = UpworkSearchPage.get_jobs_from_page(keyword)
        Utils.send_results_to_slack(channel='job-upwork',
                                    results=jobs_result,
                                    file_name=CSV_FILE_NAME)
        Utils.write_csv(jobs_result, file_name=CSV_FILE_NAME)
Example #14
0
    def open2(self):
        # костыль, чтобы проскочить njinx
        from selene import config
        config.base_url = ""

        open_url(
            'http://qualitycentral.snap.dev.local/web/administration/#/statistics'
        )
        return self
Example #15
0
def test_filter_tasks():
    browser.open_url('file://' + os.path.abspath(os.path.dirname(__file__)) +
                     '/../../resources/todomvcapp/home.html')

    s('#new-todo').should(be.enabled).set_value('a').press_enter()
    s('#new-todo').should(be.enabled).set_value('b').press_enter()
    s('#new-todo').should(be.enabled).set_value('c').press_enter()

    ss("#todo-list>li").should(have.texts('a', 'b', 'c'))
Example #16
0
def additional_tab():
    def switch(num=0):
        browser.driver().switch_to.window(browser.driver().window_handles[num])

    browser.driver().execute_script("window.open('');")
    switch(1)
    browser.open_url(CURRENT_SPRINT)
    switch(0)
    yield switch
Example #17
0
    def open3(self):
        # костыль, чтобы проскочить ninx
        #   from selene import config
        #  config.base_url = ""

        open_url(
            'http://qualitycentral.snap.dev.local/web/administration/#/branchs/'
        )
        return self
Example #18
0
 def screenshot(self, url, file_name):
     print("Capturing", url, "screenshot as", file_name, "...")
     print("before opening")
     browser.open_url(url)
     print("after opening")
     browser.driver().set_window_size(1024, 768)
     print("SAVING HERE:", os.path.join(os.path.dirname(os.path.realpath(__file__)), 'screenshots', file_name))
     browser.driver().get_screenshot_as_file(
         os.path.join(os.path.dirname(os.path.realpath(__file__)), 'screenshots', file_name))
     print("Done.")
Example #19
0
def test_can_save_screenshot_to_custom_folder_with_custom_name():
    screenshot_folder = os.path.dirname(os.path.abspath(__file__)) + '/../../build/screenshots'
    open_url(start_page)
    actual = take_screenshot(path=screenshot_folder,
                             filename="custom_file_in_custom_folder")

    expected = os.path.join(screenshot_folder, 'custom_file_in_custom_folder.png')
    assert expected == actual
    assert os.path.isfile(actual)
    assert os.path.exists(actual)
Example #20
0
def test_can_save_screenshot_to_custom_folder_specified_through_config():
    config.reports_folder = os.path.dirname(os.path.abspath(__file__)) + '/../../build/screenshots'
    open_url(start_page)
    actual = take_screenshot()

    expected = os.path.join(get_default_screenshot_folder(),
                            'screen_{id}.png'.format(id=get_screen_id()))
    assert expected == actual
    assert os.path.isfile(actual)
    assert os.path.exists(actual)
def authenticate():
    logging.info("authentication has been initiated.")
    browser.open_url(base_url)

    page.login.should(be.visible).set(credentials['username'])
    page.password.should(be.visible).set(credentials['password'])
    page.submit.click()

    browser.should(have.url(urljoin(base_url, "dashboard")))
    logging.info("authentication has been successful.")
Example #22
0
def test_can_save_screenshot_to_custom_folder_specified_as_parameter():
    screenshot_folder = os.path.dirname(os.path.abspath(__file__)) + '/../../build/screenshots'
    open_url(start_page)
    actual = take_screenshot(path=screenshot_folder)

    expected = os.path.join(screenshot_folder,
                            'screen_{id}.png'.format(id=get_screen_id()))
    assert expected == actual
    assert os.path.isfile(actual)
    assert os.path.exists(actual)
Example #23
0
    def test_send_new_jobs_to_slack(self, wd, keyword):
        config.base_url = 'https://www.fl.ru/projects/'

        open_url("")
        FlruSearchPage.search_job(keyword)
        jobs_result = FlruSearchPage.get_jobs_from_page(keyword)
        Utils.send_results_to_slack(channel='job-flru',
                                    results=jobs_result,
                                    file_name=CSV_FILE_NAME)
        Utils.write_csv(jobs_result, file_name=CSV_FILE_NAME)
        Utils.write_xlsx(jobs_result, file_name=XLSX_FILE_NAME)
Example #24
0
def test_can_scroll_to_via_js():
    browser.open_url(start_page)
    logging.warning(browser.driver().current_url)
    browser.driver().set_window_size(300, 400)
    link = s("#invisible_link")
    # browser.driver().execute_script("arguments[0].scrollIntoView();", link)
    # - this code does not work because SeleneElement is not JSON serializable, and I don't know the way to fix it
    #   - because all available in python options needs a change to json.dumps call - adding a second parameter to it
    #     and specify a custom encoder, but we can't change this call inside selenium webdriver implementation
    browser.driver().execute_script("arguments[0].scrollIntoView();", link.get_actual_webelement())
    link.click()
Example #25
0
def test_filter_tasks():
    browser.open_url('file://' + os.path.abspath(os.path.dirname(__file__)) + '/../../resources/todomvcapp/home.html')

    s('#new-todo').should(be.enabled).set_value('a').press_enter()
    s('#new-todo').should(be.enabled).set_value('b').press_enter()
    s('#new-todo').should(be.enabled).set_value('c').press_enter()

    config.timeout = 0.5
    with pytest.raises(TimeoutException) as ex:
        ss("#todo-list>li").should(have.size(3))

    assert "actual: 6" in ex.value.msg
Example #26
0
 def test_qa_vacancy(self):
     try:
         browser.open_url('employer/1886264')
         wait_for_page_load("//h3[text()='Вакансии компании']")
         qa_vacancy = browser.element(
             by.xpath(
                 "//span[contains(text(), 'Вакансии в текущем регионе')]/ancestor::h4/following-sibling::div//a[text()='QA Automation Engineer']"
             ))
         assert qa_vacancy.should(be.visible)
     except NoSuchElementException as e:
         print("Element was not found. Exception was caught: %s" % e)
         raise e
Example #27
0
 def test_vacancies_number(self):
     try:
         browser.open_url('employer/1886264')
         wait_for_page_load("//h3[text()='Вакансии компании']")
         vacancies_number = browser.element(
             by.xpath(
                 "//span[contains(text(), 'Вакансии в текущем регионе')]/following-sibling::span"
             )).text
         assert int(vacancies_number) == 8
         #number of vacancies is changed from 9 to 8 due to changes on the site
     except NoSuchElementException as e:
         print("Element was not found. Exception was caught: %s" % e)
         raise e
Example #28
0
def setup_function(f):
    global browser
    global shaded_browser

    set_driver(get_test_driver())
    open_url(TODOMVC_URL)
    s("#new-todo").should_be(visible)

    browser = get_test_driver()
    browser.get(TODOMVC_URL)
    WebDriverWait(browser, 4).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, "#new-todo")))

    shaded_browser = get_test_driver()
def xtest_add_tasks():
    browser.open_url(todomvc_url)
    browser.should(have.js_returned_true(is_TodoMVC_loaded))

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()

    config.timeout = 0.5
    with pytest.raises(TimeoutException) as ex:
        ss("#todo-list>li").should(have.size(3))

    assert "actual: 6" in ex.value.msg
Example #30
0
 def get_jobs_from_pages(keyword):
     jobs_info = []
     page_num = 1
     while True:
         open_url("{_page_num}?keyword={_keyword}".format(
             _page_num=page_num, _keyword=keyword))
         jobs_el = ss(FreelancercomLocators.JOB_LIST)
         jobs = FreelancerSearchPage.get_jobs_from_page(jobs_el)
         if jobs:
             jobs_info.extend(jobs)
             page_num += 1
         else:
             break
     return jobs_info