Skip to content

Commit

Permalink
Test localized date input in Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
koterpillar committed Oct 31, 2016
1 parent eeb6ab8 commit 3b22baa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
17 changes: 14 additions & 3 deletions aloe_webdriver/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ def browser_type():
return os.environ.get('BROWSER_TYPE', 'firefox')


def skip_if_browser(browser, message):
def skip_if_browser(browsers, message):
"""Decorator to skip a test with a particular browser type."""

if browser_type() == browser:
if not isinstance(browsers, (list, tuple)):
browsers = [browsers]

if browser_type() in browsers:
return unittest.skip(message)
return lambda func: func

Expand Down Expand Up @@ -173,4 +176,12 @@ def create_browser():
'phantomjs': webdriver.PhantomJS,
}
driver = browsers[browser_type()]
return driver()

# Explicitly specify the browser locale for the date input tests to work
# regardless of the user's settings
old_lc_all = os.environ.get('LC_ALL', '')
try:
os.environ['LC_ALL'] = 'en_US'
return driver()
finally:
os.environ['LC_ALL'] = old_lc_all
21 changes: 18 additions & 3 deletions aloe_webdriver/tests/test_webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,22 @@ def test_input_values_fail(self):
Then input "username" has value "Ricky"
"""

# Chrome's date fields are in a localized format (e.g. DD-MM-YYYY)
# Chrome's date fields expect input in a localized format, for example,
# mm/dd/yyyy for en_US (note day and month swapped vis-a-vis ISO format).
# The test browser locale is set to en_US.

@skip_if_browser(
['firefox', 'phantomjs'],
"Only Chrome's date fields are in a localized format."
)
@feature()
def test_date_input_localized(self):
"""
When I visit test page "basic_page"
And I fill in "dob" with "02141992"
Then input "dob" has value "1992-02-14"
"""

@skip_if_browser(
'chrome',
"Chrome's date fields are in a localized format."
Expand All @@ -234,8 +249,8 @@ def test_input_values_fail(self):
def test_date_input(self):
"""
When I visit test page "basic_page"
And I fill in "dob" with "1900-01-01"
Then input "dob" has value "1900-01-01"
And I fill in "dob" with "1992-02-14"
Then input "dob" has value "1992-02-14"
"""

@feature()
Expand Down

0 comments on commit 3b22baa

Please sign in to comment.