示例#1
0
def test_wait_with_ec_invisible(driver, wait):
    # Case 1 - Should report passed.
    LoginPage(driver).open().login_as("John Smith", "12345")
    # Check successful login.
    assert ProfilePage(driver).greetings_are_displayed() is True
    ProfilePage(driver).logout()
    # Greeting label shouldn't be shown anymore after logout.
    textlabel_greetings = (By.CSS_SELECTOR, "#greetings")
    element_not_present = wait.until(ec.invisibility_of_element_located(textlabel_greetings))
    assert element_not_present
    # Case 2 - Should report failed.
    try:
        wait.until(ec.title_is("Title that is definitely not this one."))
    except TimeoutException:
        pass
    # Case 3 - Report with StepSettings
    # Inverting result and taking picture on success.
    # Wait should timeout and report fail which will be inverted to passed and include picture.
    with DriverStepSettings(driver=wait.driver,
                            step_settings=StepSettings(invert_result=True,
                                                       screenshot_condition=TakeScreenshotConditionType.Failure)):
        try:
            wait.until_not(ec.url_contains("TestProject"))
        except TimeoutException:
            pass
示例#2
0
def test_update_profile_expect_success_message_to_be_displayed(driver):

    LoginPage(driver).open().login_as("John Smith", "12345")
    ProfilePage(driver).update_profile(
        country="Australia", address="Main Street 123", email="*****@*****.**", phone="+1987654321",
    )
    assert ProfilePage(driver).saved_message_is_displayed()
def test_update_profile_again_expect_success_message_to_be_displayed(driver):

    LoginPage(driver).open().login_as("Bob Jones", "12345")
    ProfilePage(driver).update_profile(
        country="Canada",
        address="Maple Street 456",
        email="*****@*****.**",
        phone="+1123456789",
    )
    assert ProfilePage(driver).saved_message_is_displayed()
def test_wait_with_ec_invisible(driver, wait):
    # Driver command will fail because element will not be found but this is the expected result so this step actually
    # passes and will reported as passed as well.
    LoginPage(driver).open().login_as("John Smith", "12345")
    # Check successful login.
    assert ProfilePage(driver).greetings_are_displayed() is True
    ProfilePage(driver).logout()
    # Greeting label shouldn't be shown anymore after logout.
    textlabel_greetings = (By.CSS_SELECTOR, "#greetings")
    element_not_present = wait.until(ec.invisibility_of_element_located(textlabel_greetings))
    assert element_not_present
    # This step will fail because the example page's title is not the one we give below, step will be reported as failed
    # and a TimeoutException will arose by the WebDriverWait instance.
    try:
        wait.until(ec.title_is("Title that is definitely not this one."))
    except TimeoutException:
        pass
def test_is_reported_as_failed_with_additional_step(driver):
    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
    driver.report().step(
        description="Failing step with screenshot",
        message="An additional message that goes with the step",
        passed=False,
        screenshot=True,
    )
    driver.report().test(name="Failing test", passed=False)
示例#6
0
def test_is_reported_as_failed_with_additional_step(driver):
    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
    driver.report().step(
        description="Failing step with screenshot",
        message="An additional message that goes with the step",
        passed=False,
        screenshot=True,
        element=ElementSearchCriteria(FindByType.ID, "the_ID_value"),
        inputs={
            "parameter_name_x": "any_object_value_of_x",
            "another_parameter_y": True
        })
    driver.report().test(name="Failing test", passed=False)
def test_example_on_safari_on_ios(driver):

    LoginPage(driver).open().login_as("John Smith", "12345")

    profile_page = ProfilePage(driver)

    profile_page.update_profile(
        "United States",
        "Street name and number",
        "*****@*****.**",
        "+1 555 555 55",
    )

    assert profile_page.saved_message_is_displayed() is True
示例#8
0
def test_example_using_internet_explorer(driver):

    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
示例#9
0
 def test_login_to_testproject_demo_app(self):
     driver = webdriver.Chrome()
     LoginPage(driver).open().login_as("John Smith", "12345")
     assert ProfilePage(driver).greetings_are_displayed() is True
     driver.quit()
示例#10
0
def test_is_reported_as_passed(driver):
    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
    driver.report().test(name="Passing test", passed=True)
示例#11
0
def test_example_using_chrome():
    driver = webdriver.Chrome()
    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
    driver.quit()
示例#12
0
def test_basic_flow_with_forced_exception_should_fail(driver):

    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True
    # This element does not exist, so this action will force the test to fail
    driver.find_element(By.CSS_SELECTOR, "#does_not_exist").click()
示例#13
0
def test_basic_flow_should_pass(driver):

    LoginPage(driver).open().login_as("John Smith", "12345")
    assert ProfilePage(driver).greetings_are_displayed() is True