summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Ferraz <tiago.ferraz@gmail.com>2015-03-26 18:03:21 -0300
committerTiago Ferraz <tiago.ferraz@gmail.com>2015-03-26 18:03:21 -0300
commitbe5438f6ec57cea20e0ca92d43dd2189f19f29d0 (patch)
tree8d9d51e03b22aecbb27c574f4a495c53c3a00195
parent290cefcf6911e754cd129c02dda3d1e96dd7fa27 (diff)
Refactorating: replaced XPath by CSS Selector
-rw-r--r--service/test/functional/features/forward_trash_archive.feature4
-rw-r--r--service/test/functional/features/steps/common.py5
-rw-r--r--service/test/functional/features/steps/compose.py4
-rw-r--r--service/test/functional/features/steps/mail_list.py13
-rw-r--r--service/test/functional/features/steps/mail_view.py4
-rw-r--r--service/test/functional/features/steps/tag_list.py3
6 files changed, 20 insertions, 13 deletions
diff --git a/service/test/functional/features/forward_trash_archive.feature b/service/test/functional/features/forward_trash_archive.feature
index 85c422d9..6e959c32 100644
--- a/service/test/functional/features/forward_trash_archive.feature
+++ b/service/test/functional/features/forward_trash_archive.feature
@@ -29,4 +29,6 @@ Feature: forward and deletion
When I open the first mail in the 'sent'
Then I see the mail has a cc and a bcc recipient
When I choose to trash
- Then I see that mail under the 'trash' tag
+# Then I see that mail under the 'trash' tag
+ When I select the tag 'trash'
+ And I open the first mail in the mail list \ No newline at end of file
diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py
index 4d5a0ef7..93f4cb1f 100644
--- a/service/test/functional/features/steps/common.py
+++ b/service/test/functional/features/steps/common.py
@@ -58,6 +58,11 @@ def fill_by_xpath(context, xpath, text):
field.send_keys(text)
+def fill_by_css_selector(context, css_selector, text):
+ field = context.browser.find_element_by_css_selector(css_selector)
+ field.send_keys(text)
+
+
def take_screenshot(context, filename):
context.browser.save_screenshot(filename)
diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py
index 1f7f1eb7..668579b1 100644
--- a/service/test/functional/features/steps/compose.py
+++ b/service/test/functional/features/steps/compose.py
@@ -26,8 +26,8 @@ def impl(context):
toggle.click()
for row in context.table:
- fill_by_xpath(context, '//*[@id="subject"]', row['subject'])
- fill_by_xpath(context, '//*[@id="text-box"]', row['body'])
+ fill_by_css_selector(context, 'input#subject', row['subject'])
+ fill_by_css_selector(context, 'textarea#text-box', row['body'])
@when("for the '{recipients_field}' field I enter '{to_type}'")
diff --git a/service/test/functional/features/steps/mail_list.py b/service/test/functional/features/steps/mail_list.py
index dc15c1a9..5f0a0116 100644
--- a/service/test/functional/features/steps/mail_list.py
+++ b/service/test/functional/features/steps/mail_list.py
@@ -46,7 +46,7 @@ def impl(context):
@when('I open the first mail in the mail list')
def impl(context):
- first_email = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))[0]
+ first_email = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-list li span a'))[0]
context.current_mail_id = 'mail-' + first_email.get_attribute('href').split('/')[-1]
first_email.click()
sleep(5)
@@ -71,19 +71,18 @@ def impl(context):
@then('the deleted mail is there')
def impl(context):
- # wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
find_current_mail(context)
@given('I have mails')
def impl(context):
- emails = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
+ emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-list li span a'))
assert len(emails) > 0
@when('I mark the first unread email as read')
def impl(context):
- emails = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//li'))
+ emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-list li'))
for email in emails:
if 'status-read' not in email.get_attribute('class'):
@@ -98,11 +97,11 @@ def impl(context):
@when('I delete the email')
def impl(context):
def last_email():
- return wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//li'))[0]
+ return wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-list li'))[0]
context.current_mail_id = last_email().get_attribute('id')
last_email().find_element_by_tag_name('input').click()
find_element_by_id(context, 'delete-selected').click()
- assert context.current_mail_id != find_elements_by_xpath(context, '//*[@id="mail-list"]//a')[0]
+ assert context.current_mail_id != find_elements_by_css_selector(context, '#mail-list li span a')[0]
@when('I check all emails')
@@ -118,7 +117,7 @@ def impl(context):
@then('I should not see any email')
def impl(context):
try:
- context.browser.find_element_by_xpath('//*[@id="mail-list"]//a')
+ context.browser.find_element(By.CSS_SELECTOR, '#mail-list li span a')
except NoSuchElementException:
assert True
except:
diff --git a/service/test/functional/features/steps/mail_view.py b/service/test/functional/features/steps/mail_view.py
index 7a7c34b8..7a44f62d 100644
--- a/service/test/functional/features/steps/mail_view.py
+++ b/service/test/functional/features/steps/mail_view.py
@@ -31,7 +31,7 @@ def impl(context, expected_body):
@then('that email has the \'{tag}\' tag')
def impl(context, tag):
- wait_until_element_is_visible_by_locator(context, (By.CSS, '#mail-view .tagsArea .tag'))
+ wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '#mail-view .tagsArea .tag'))
elements = find_elements_by_css_selector(context, '#mail-view .tagsArea .tag')
tags = [e.text for e in elements]
assert tag in tags
@@ -45,7 +45,7 @@ def impl(context, tag):
e = wait_until_element_is_visible_by_locator(context, (By.ID, 'new-tag-input'))
e.send_keys(tag)
e.send_keys(Keys.ENTER)
- wait_until_element_is_visible_by_locator(context, (By.XPATH, '//li[@data-tag="%s"]' % tag))
+ wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, 'li[data-tag=%s]' % tag))
@when('I reply to it')
diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py
index 8e4db470..b3e09c22 100644
--- a/service/test/functional/features/steps/tag_list.py
+++ b/service/test/functional/features/steps/tag_list.py
@@ -41,8 +41,9 @@ def impl(context, tag):
wait_until_element_is_visible_by_locator(context, (By.ID, 'tag-%s' % tag), 20)
- e = find_element_by_id(context, 'tag-%s' % tag.lower())
+ e = find_element_by_id(context, 'tag-%s' % tag)
e.click()
+ wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, "#mail-list li span a[href*='%s']" % tag))
@when('I am in \'{tag}\'')