Пример #1
0
 def test_02(self):
     login(self.driver, "admin", "524")
     time.sleep(3)
     hh = self.driver.find_element_by_xpath(
         "html/body/div[2]/div/span/div/div/div/span").text
     print(hh)
     self.assertTrue(hh == "用户名或密码错误")
Пример #2
0
 def test_01(self):
     login(self.driver)
     time.sleep(3)
     t1 = self.driver.find_element_by_xpath(
         ".//*[@id='root']/div/div/section/section/header/ul/li/div/div/span"
     ).text
     self.assertTrue(t1 == "超级管理员")
Пример #3
0
def test_login():
    get(login_page)
    assert_on_login()
    login_page.login((name, password))
    get(home_page)
    assert_on_home_page()
    home_page.logout()
    assert_on_login()
Пример #4
0
def step_impl(context, email, password):
    login_page.login_url(context)
    login_page.login(context, email, password)
    login_page.arrive_in_dashboard(context)
Пример #5
0
def step_impl(context, username, password):
    login_page.login(context, username, password)
Пример #6
0
def step_impl(context, email, password):
  login_page.login_url(context)
  login_page.login(context, email, password)
Пример #7
0
def setup(setup_test_repo, setup_test_products):
    lcc.log_info("Initialising the webdriver object, opening the browser...")
    # Initialise the global webdriver, open the browser and maximise the
    # browser window
    if headless == "yes":
        options = Options()
        options.add_argument('--headless')
        options.add_argument('--no-sandbox')
        options.add_argument('--window-size=1920,1080')
        options.add_argument('--disable-gpu')
        options.add_argument('--disable-dev-shm-usage')
        options.add_argument('--proxy-server=%s' % proxy_url)
        # options.add_argument('--proxy-auto-detect')
        # driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options)
        driver = webdriver.Chrome(ChromeDriverManager(path=os.environ['PYTHONPATH']).install(), chrome_options=options)
        driver.maximize_window()
        logging.info("Webdriver has been initialised successfully in headless mode...")
    else:
        options = Options()
        options.add_argument('--proxy-server=%s' % proxy_url)
        #options.add_argument('--proxy-auto-detect')
        # caps = DesiredCapabilities.FIREFOX.copy()
        # caps["marionette"] = False
        # driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options, capabilities=caps)

        driver = webdriver.Chrome(ChromeDriverManager(path=os.environ['PYTHONPATH']).install(),chrome_options=options)
        logging.info("Webdriver has been initialised successfully")

    driver.maximize_window()
    driver.implicitly_wait(15)
    driver.get(url)
    lcc.log_info(driver.current_url)
    # login to Pantheon v2
    lcc.log_info("Log in to Pantheon v2 using credentials")
    login_page.login(driver)
    # the global driver object can be used globally in the tests.
    yield driver

    # This block of code is the teardown method which deletes the repository
    # created and closes the browser window.

    # # This block of code is the teardown method which deletes the repository uploaded for testing
    lcc.log_info("Starting with teardown")
    lcc.log_info("Deleting the test-repo from QA env...")
    time.sleep(10)
    path_to_repo = url + "bin/cpm/nodes/node.json/content/repositories/" + test_repo_name
    lcc.log_info("Test repo node being deleted at: %s" % path_to_repo)
    response = requests.delete(path_to_repo, auth=(admin_username, admin_auth))
    print(response.status_code)
    # poll(lambda: response.status_code == 200, step=10, timeout=300)
    # print(response.status_code)
    # time.sleep(200)
    check_that("The test repo was deleted successfully",
               response.status_code, equal_to(200))
    time.sleep(15)

    # Deleting the git repo uploaded via git import in the test suite.
    path_to_git_repo = url + "bin/cpm/nodes/node.json/content/repositories/" + git_import_repo
    lcc.log_info("Test repo node used for git import functionality being deleted at: %s" % path_to_git_repo)
    response_git_delete = requests.delete(path_to_git_repo, auth=(admin_username, admin_auth))
    print(str(response_git_delete.content))
    check_that(
        "The git import test repo was deleted successfully from backend", response_git_delete.status_code,
        equal_to(200))

    # This block of code is the teardown method which deletes the product created for testing
    path_to_new_product_node = url + "bin/cpm/nodes/node.json/content/products/" + constants.product_name_uri
    lcc.log_info("Test Product node being deleted at: %s" % path_to_new_product_node)
    response1 = requests.delete(path_to_new_product_node, auth=(admin_username, admin_auth))
    print(str(response1.content))
    check_that("Test product version created was deleted successfully",
               response1.status_code, equal_to(200))
    time.sleep(15)

    lcc.log_info("Closing the browser window...")
    driver.close()
    driver.quit()