-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_submit_contact.py
61 lines (49 loc) · 1.93 KB
/
test_submit_contact.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# coding=utf-8
"""Submit a valid contact form feature tests."""
from pytest_bdd import (
given,
scenario,
then,
when,
)
import pytest
from selenium import webdriver
@pytest.fixture(autouse=True, scope='module')
def setup(request):
global driver
driver = webdriver.Chrome("/Users/yuxuan.zhao/chromedriver")
def fin():
driver.quit()
request.addfinalizer(fin)
@scenario('SubmitContact.feature', 'Submit form using valid data')
def test_submit_form_using_valid_data():
"""Submit form using valid data."""
@given('I am on the zoo website')
def i_am_on_the_zoo_website():
"""I am on the zoo website."""
driver.get("http://www.thetestroom.com/webapp/")
@when('I navigate to "contact_link"')
def i_navigate_to_contact_link():
"""I navigate to "contact_link"."""
driver.find_element_by_id("contact_link").click()
@when('I submit the form with valid data')
def i_submit_the_form_with_valid_data():
"""I submit the form with valid data."""
#driver.find_element_by_name("name_field").sendKeys(data.get(1).get(1))
#driver.find_element_by_name("address_field").sendKeys(data.get(2).get(1))
#driver.find_element_by_name("postcode_field").sendKeys(data.get(3).get(1))
#driver.find_element_by_name("email_field").sendKeys(data.get(4).get(1))
driver.find_element_by_name("name_field").send_keys("Chris")
driver.find_element_by_name("address_field").send_keys("Galaxy")
driver.find_element_by_name("postcode_field").send_keys("P2D F3F")
driver.find_element_by_name("email_field").send_keys("light@star.com")
@then('I check that the form has been subimtted')
def i_check_that_the_form_has_been_subimtted():
"""I check that the form has been subimtted."""
driver.find_element_by_id("submit_message").click()
assert "Contact Confirmation" in driver.title
@then('I close the browser')
def i_close_the_browser():
"""I close the browser."""
driver.close()
driver.quit()