summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-08-20 17:21:20 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-08-20 17:45:12 +0200
commitae6f773d4abc42dcc0eaa1c70f8af14b091f8d47 (patch)
tree15e5df69a6d1b774042dfd29372115a1baf4136f
parenta3ea808b6290a7c756b28099df9fa8574c94055e (diff)
Translated cucumber tests to behave.
-rw-r--r--py-fake-service/features/compose_save_draft_and_send.feature14
-rw-r--r--py-fake-service/features/environment.py23
-rw-r--r--py-fake-service/features/forward_trash_archive.feature12
-rw-r--r--py-fake-service/features/search_and_destroy.feature11
-rw-r--r--py-fake-service/features/step_definitions/compose.rb27
-rw-r--r--py-fake-service/features/step_definitions/mail_list.rb55
-rw-r--r--py-fake-service/features/step_definitions/mail_view.rb67
-rw-r--r--py-fake-service/features/step_definitions/search.rb12
-rw-r--r--py-fake-service/features/step_definitions/tag_list.rb15
-rw-r--r--py-fake-service/features/steps/__init__.py0
-rw-r--r--py-fake-service/features/steps/common.py68
-rw-r--r--py-fake-service/features/steps/compose.py58
-rw-r--r--py-fake-service/features/steps/mail_list.py49
-rw-r--r--py-fake-service/features/steps/mail_view.py81
-rw-r--r--py-fake-service/features/steps/search.py18
-rw-r--r--py-fake-service/features/steps/tag_list.py18
-rw-r--r--py-fake-service/features/support/env.rb31
-rw-r--r--py-fake-service/features/tag_and_reply.feature12
-rw-r--r--py-fake-service/requirements.txt3
19 files changed, 574 insertions, 0 deletions
diff --git a/py-fake-service/features/compose_save_draft_and_send.feature b/py-fake-service/features/compose_save_draft_and_send.feature
new file mode 100644
index 00000000..fcff4a95
--- /dev/null
+++ b/py-fake-service/features/compose_save_draft_and_send.feature
@@ -0,0 +1,14 @@
+Feature: compose mail, save draft and send mail
+
+ @wip
+ Scenario: user composes and email, save the draft, later sends the draft and checks the sent message
+ Given I compose a message with
+ | subject | body |
+ | Pixelated rocks! | You should definitely use it. Cheers, User. |
+ And for the 'To' field I type 'ab' and chose the first contact that shows
+ And I save the draft
+ When I open the saved draft and send it
+ Then I see that mail under the 'sent' tag
+ When I open that mail
+ Then I see that the subject reads 'Pixelated rocks!'
+ And I see that the body reads 'You should definitely use it. Cheers, User.'
diff --git a/py-fake-service/features/environment.py b/py-fake-service/features/environment.py
new file mode 100644
index 00000000..0ec3558e
--- /dev/null
+++ b/py-fake-service/features/environment.py
@@ -0,0 +1,23 @@
+from selenium import webdriver
+
+
+def before_feature(context, feature):
+ #context.browser = webdriver.Firefox()
+ context.browser = webdriver.PhantomJS()
+ context.browser.set_window_size(1280, 1024)
+ context.browser.implicitly_wait(5)
+ context.browser.set_page_load_timeout(60) # wait for data
+ context.browser.get('http://localhost:4567/')
+
+
+def after_feature(context, feature):
+ context.browser.quit()
+
+
+def take_screenshot(context):
+ context.browser.save_screenshot('/tmp/screenshot.jpeg')
+
+
+def save_source(context):
+ with open('/tmp/source.html', 'w') as out:
+ out.write(context.browser.page_source.encode('utf8'))
diff --git a/py-fake-service/features/forward_trash_archive.feature b/py-fake-service/features/forward_trash_archive.feature
new file mode 100644
index 00000000..baa1ad2c
--- /dev/null
+++ b/py-fake-service/features/forward_trash_archive.feature
@@ -0,0 +1,12 @@
+Feature: forward_trash_archive
+ Scenario: User forwards a mail, add CC and BCC address, later trash and archive the mail
+ When I open the first mail in the 'inbox'
+ Then I choose to forward this mail
+ And for the 'CC' field I type 'ab' and chose the first contact that shows
+ And for the 'Bcc' field I type 'fr' and chose the first contact that shows
+ And I forward this mail
+ When I open the first mail in the 'sent'
+ Then I see the mail has a cc and a bcc recipient
+ And I remove all tags
+ And I choose to trash
+ Then I see that mail under the 'trash' tag
diff --git a/py-fake-service/features/search_and_destroy.feature b/py-fake-service/features/search_and_destroy.feature
new file mode 100644
index 00000000..4a41c3f8
--- /dev/null
+++ b/py-fake-service/features/search_and_destroy.feature
@@ -0,0 +1,11 @@
+Feature: search html mail and destroy
+
+ Scenario: User searches for a mail and deletes it
+ When I search for a mail with the words "this is a html mail"
+ When I open the first mail in the mail list
+ Then I see one or more mails in the search results
+ Then I see if the mail has html content
+ When I try to delete the first mail
+ # Then I learn that the mail was deleted
+ When I select the tag 'trash'
+ Then the deleted mail is there
diff --git a/py-fake-service/features/step_definitions/compose.rb b/py-fake-service/features/step_definitions/compose.rb
new file mode 100644
index 00000000..e92d16f6
--- /dev/null
+++ b/py-fake-service/features/step_definitions/compose.rb
@@ -0,0 +1,27 @@
+Given /^I compose a message with$/ do |table|
+ find('#compose-mails-trigger').click
+ data = table.hashes.first
+ fill_in('Subject', with: data['subject'])
+ fill_in('Body', with: data['body'])
+end
+
+Given /^for the '(.*)' field I type '(.*)' and chose the first contact that shows$/ do |recipients_field, to_type|
+ recipients_field.downcase!
+ within("#recipients-#{recipients_field}-area") do
+ find('.tt-input').native.send_keys(to_type)
+ sleep 1
+ first('.tt-dropdown-menu div div').click
+ end
+end
+
+Given /^I save the draft$/ do
+ click_button("Save Draft")
+end
+
+When /^I open the saved draft and send it$/ do
+ step "I select the tag 'drafts'"
+ step "I open the first mail in the mail list"
+ page.should_not have_css("#send-button[disabled]")
+ click_button('Send')
+ find('#user-alerts').should have_content("Your message was sent!")
+end
diff --git a/py-fake-service/features/step_definitions/mail_list.rb b/py-fake-service/features/step_definitions/mail_list.rb
new file mode 100644
index 00000000..d41a62a0
--- /dev/null
+++ b/py-fake-service/features/step_definitions/mail_list.rb
@@ -0,0 +1,55 @@
+When(/^I open the first mail in the '(.*)'$/) do |tag|
+ page.execute_script("window.scrollBy(0, -200)")
+ step "I select the tag '#{tag}'"
+ step 'I open the first mail in the mail list'
+end
+
+When(/^I open the first mail in the mail list$/) do
+ within('#mail-list') do
+ mail_link = first('a')
+ @current_mail_id = mail_link.native.attribute('href').scan(/\/(\d+)$/).flatten.first
+ begin
+ mail_link.click
+ rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li'
+ mail_link_parent_li = mail_link.find(:xpath, '../..')
+ mail_link_parent_li.click
+ end
+ end
+end
+
+When(/I see that mail under the '(.*)' tag/) do |tag|
+ step "I select the tag '#{tag}'"
+ check_current_mail_is_visible
+end
+
+And(/^I open the mail I previously tagged$/) do
+ open_current_mail
+end
+
+When(/^I open that mail$/) do
+ open_current_mail
+end
+
+Then(/^I see the mail I sent$/) do
+ check_current_mail_is_visible
+end
+
+Then(/^the deleted mail is there$/) do
+ check_current_mail_is_visible
+end
+
+def open_current_mail
+ within('#mail-list') do
+ begin
+ first("#mail-#{@current_mail_id} a").click
+ rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li'
+ first("#mail-#{@current_mail_id}").click
+ end
+ end
+end
+
+def check_current_mail_is_visible
+ within('#mail-list') do
+ have_selector?("#mail-#{@current_mail_id}").should be_true
+ end
+end
diff --git a/py-fake-service/features/step_definitions/mail_view.rb b/py-fake-service/features/step_definitions/mail_view.rb
new file mode 100644
index 00000000..19ca5736
--- /dev/null
+++ b/py-fake-service/features/step_definitions/mail_view.rb
@@ -0,0 +1,67 @@
+A_MAIL = /[^\s@]+@[^\s@]+\.[^\s@]+/
+
+Then(/^I see the mail has a cc and a bcc recipient$/) do
+ within('.msg-header') do
+ first('.cc').text.should =~ A_MAIL
+ first('.bcc').text.should =~ A_MAIL
+ end
+end
+
+Then(/^that email has the '(.*)' tag$/) do |tag|
+ within('#mail-view') do |e|
+ all('.tagsArea .tag').map(&:text).map(&:downcase).to_a.should include(tag)
+ end
+end
+
+When(/I add the tag '(.*)' to that mail/) do |tag|
+ page.execute_script("$('#new-tag-button').click();")
+ page.execute_script("$('#new-tag-input').val('#{tag}');")
+ find('#new-tag-input').native.send_keys [:return]
+end
+
+And(/^I reply to it$/) do
+ click_button('Reply')
+ click_button('Send')
+end
+
+Then(/^I choose to forward this mail$/) do
+ click_button('Forward')
+end
+
+Then(/^I forward this mail$/) do
+ click_button('Send')
+end
+
+
+Then(/^I remove all tags$/) do
+ within('.tagsArea') do
+ all('.tag').each do |tag|
+ tag.click
+ end
+ end
+end
+
+Then(/^I choose to trash$/) do
+ click_button('Trash message')
+end
+
+When(/^I try to delete the first mail$/) do
+ step 'I open the first mail in the mail list'
+ within('#mail-view') do
+ page.driver.find_css('#view-more-actions')[0].click
+ page.driver.execute_script("$('#delete-button-top').click();")
+ end
+ find('#user-alerts').text.should == 'Your message was moved to trash!'
+end
+
+Then(/^I see that the subject reads '(.*)'$/) do |expected_subject|
+ find('#mail-view .subject').text.should == expected_subject
+end
+
+Then(/^I see that the body reads '(.*)'$/) do |expected_body|
+ find('#mail-view .bodyArea').text.should == expected_body
+end
+
+Then(/^I see if the mail has html content/) do
+ find('#mail-view .bodyArea').should have_css('h2[style*=\'color: #3f4944\']', :text => "cborim")
+end
diff --git a/py-fake-service/features/step_definitions/search.rb b/py-fake-service/features/step_definitions/search.rb
new file mode 100644
index 00000000..de89759c
--- /dev/null
+++ b/py-fake-service/features/step_definitions/search.rb
@@ -0,0 +1,12 @@
+When(/^I search for a mail with the words "(.*)"$/) do |search_term|
+ search_field = find('#search-trigger input[type="search"]').native
+ search_field.send_keys(search_term)
+ search_field.send_keys(:return)
+end
+
+Then(/^I see one or more mails in the search results$/) do
+ within('#mail-list') do
+ all('li').length.should >= 1
+ end
+end
+
diff --git a/py-fake-service/features/step_definitions/tag_list.rb b/py-fake-service/features/step_definitions/tag_list.rb
new file mode 100644
index 00000000..678f5ce9
--- /dev/null
+++ b/py-fake-service/features/step_definitions/tag_list.rb
@@ -0,0 +1,15 @@
+When(/^I select the tag '(.*)'$/) do |tag|
+ wait_for_user_alert_to_disapear # in Chrome, the 'flash message is on top of the toggle
+ first('.left-off-canvas-toggle').click
+ page.execute_script("window.scrollBy(0, -200)")
+ within('#tag-list') { find('li', text: /#{tag}/i).click }
+end
+
+def wait_for_user_alert_to_disapear
+ begin
+ while find('#user-alerts')
+ sleep 0.1
+ end
+ rescue #if it couldn't find it, go ahead
+ end
+end
diff --git a/py-fake-service/features/steps/__init__.py b/py-fake-service/features/steps/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/py-fake-service/features/steps/__init__.py
diff --git a/py-fake-service/features/steps/common.py b/py-fake-service/features/steps/common.py
new file mode 100644
index 00000000..450bd9b2
--- /dev/null
+++ b/py-fake-service/features/steps/common.py
@@ -0,0 +1,68 @@
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
+from selenium.common.exceptions import NoSuchElementException
+from hamcrest import *
+
+def wait_until_element_is_invisible_by_locator(context, locator_tuple):
+ wait = WebDriverWait(context.browser, 10)
+ wait.until(EC.invisibility_of_element_located(locator_tuple))
+
+def wait_for_user_alert_to_disapear(context):
+ wait_until_element_is_invisible_by_locator(context, (By.ID, 'user-alerts'))
+
+def wait_until_element_is_visible_by_locator(context, locator_tuple):
+ wait = WebDriverWait(context.browser, 10)
+ wait.until(EC.visibility_of_element_located(locator_tuple))
+
+
+def fill_by_xpath(context, xpath, text):
+ field = context.browser.find_element_by_xpath(xpath)
+ field.send_keys(text)
+
+def take_screenshot(context, filename):
+ context.browser.save_screenshot(filename)
+
+def dump_source_to(context, filename):
+ with open(filename, 'w') as out:
+ out.write(context.browser.page_source.encode('utf8'))
+
+def page_has_css(context, css):
+ try:
+ find_element_by_css_selector(context, css)
+ return True
+ except NoSuchElementException:
+ return False
+
+def find_element_by_xpath(context, xpath):
+ return context.browser.find_element_by_xpath(xpath)
+
+def find_element_by_css_selector(context, css_selector):
+ return context.browser.find_element_by_css_selector(css_selector)
+
+def find_elements_by_css_selector(context, css_selector):
+ return context.browser.find_elements_by_css_selector(css_selector)
+
+def find_element_containing_text(context, text, element_type='*'):
+ return context.browser.find_element_by_xpath("//%s[contains(.,'%s')]" % (element_type, text))
+
+def element_should_have_content(context, css_selector, content):
+ e = find_element_by_css_selector(context, css_selector)
+ assert_that(e.text, equal_to(content))
+
+def wait_until_button_is_visible(context, title):
+ wait = WebDriverWait(context.browser, 10)
+ locator_tuple = (By.XPATH, ("//%s[contains(.,'%s')]" % ('button', title)))
+ wait.until(EC.visibility_of_element_located(locator_tuple))
+
+def click_button(context, title):
+ button = find_element_containing_text(context, title, element_type='button')
+ button.click()
+
+def mail_subject(context):
+ e = find_element_by_css_selector(context, '#mail-view .subject')
+ return e.text
+
+def reply_subject(context):
+ e = find_element_by_css_selector(context, '#reply-subject')
+ return e.text
diff --git a/py-fake-service/features/steps/compose.py b/py-fake-service/features/steps/compose.py
new file mode 100644
index 00000000..e013ac11
--- /dev/null
+++ b/py-fake-service/features/steps/compose.py
@@ -0,0 +1,58 @@
+from behave import given, when
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
+from time import sleep
+from common import *
+from hamcrest import *
+
+
+@given('I compose a message with')
+def impl(context):
+ take_screenshot(context, '/tmp/screenshot.jpeg')
+ toggle = context.browser.find_element_by_id('compose-mails-trigger')
+ toggle.click()
+
+ for row in context.table:
+ fill_by_xpath(context, '//*[@id="subject"]', row['subject'])
+ fill_by_xpath(context, '//*[@id="text-box"]', row['body'])
+
+@given("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")
+def choose_impl(context, recipients_field, to_type):
+ browser = context.browser
+ browser.find_element_by_css_selector(
+ '#recipients-to-area span input.tt-input'
+ ).click()
+ recipients_field = recipients_field.lower()
+ css_selector = '#recipients-%s-area' % recipients_field
+ recipients_element = browser.find_element_by_css_selector(css_selector)
+ recipients_element.find_element_by_css_selector(
+ '.tt-input'
+ ).send_keys(to_type)
+ wait_until_element_is_visible_by_locator(context, (By.CLASS_NAME, 'tt-dropdown-menu'))
+ browser.find_element_by_css_selector('.tt-dropdown-menu div div').click()
+
+@then("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")
+def choose_impl(context, recipients_field, to_type):
+ recipients_field = recipients_field.lower()
+ browser = context.browser
+ field = browser.find_element_by_css_selector(
+ '#recipients-%s-area .tt-input' % recipients_field
+ )
+ field.send_keys(to_type)
+ sleep(1)
+ find_element_by_css_selector(context, '.tt-dropdown-menu div div').click()
+
+@given('I save the draft')
+def save_impl(context):
+ context.browser.find_element_by_id('draft-button').click()
+
+
+@when('I open the saved draft and send it')
+def send_impl(context):
+ context.execute_steps(u"when I select the tag 'drafts'")
+ context.execute_steps(u"when I open the first mail in the mail list")
+ assert_that(is_not(page_has_css(context, '#send-button[disabled]')))
+ click_button(context, 'Send')
+ element_should_have_content(context, '#user-alerts', 'Your message was sent!')
+
diff --git a/py-fake-service/features/steps/mail_list.py b/py-fake-service/features/steps/mail_list.py
new file mode 100644
index 00000000..7964d0b5
--- /dev/null
+++ b/py-fake-service/features/steps/mail_list.py
@@ -0,0 +1,49 @@
+import re
+from behave import *
+from common import *
+
+def find_current_mail(context):
+ return find_element_by_xpath(context, '//*[@id="mail-list"]/li[@id="mail-%s"]//a' % context.current_mail_id)
+
+
+def check_current_mail_is_visible(context):
+ find_current_mail(context)
+
+def open_current_mail(context):
+ e = find_current_mail(context)
+ e.click()
+
+@then('I see that mail under the \'{tag}\' tag')
+def impl(context, tag):
+ context.execute_steps("when I select the tag '%s'" % tag)
+ check_current_mail_is_visible(context)
+
+@when('I open that mail')
+def impl(context):
+ open_current_mail(context)
+
+@when('I open the first mail in the mail list')
+def impl(context):
+ elements = context.browser.find_elements_by_xpath('//*[@id="mail-list"]//a')
+ context.current_mail_id = elements[0].get_attribute('href').split('/')[-1]
+ elements[0].click()
+
+@when('I open the first mail in the \'{tag}\'')
+def impl(context, tag):
+ context.browser.execute_script('window.scrollBy(0, -200)')
+ context.execute_steps(u"When I select the tag '%s'" % tag)
+ context.execute_steps(u'When I open the first mail in the mail list')
+
+@then('I open the mail I previously tagged')
+def impl(context):
+ open_current_mail(context)
+
+@then('I see the mail I sent')
+def impl(context):
+ src = context.browser.page_source
+ assert_that(src, contains_string(context.reply_subject))
+
+@then('the deleted mail is there')
+def impl(context):
+ check_current_mail_is_visible(context)
+
diff --git a/py-fake-service/features/steps/mail_view.py b/py-fake-service/features/steps/mail_view.py
new file mode 100644
index 00000000..94c1fd27
--- /dev/null
+++ b/py-fake-service/features/steps/mail_view.py
@@ -0,0 +1,81 @@
+import re
+from selenium.webdriver.common.keys import Keys
+from behave import *
+from common import *
+from hamcrest import *
+from time import sleep
+
+@then('I see that the subject reads \'{subject}\'')
+def impl(context, subject):
+ e = find_element_by_css_selector(context, '#mail-view .subject')
+ assert_that(e.text, equal_to(subject))
+
+@then('I see that the body reads \'{expected_body}\'')
+def impl(context, expected_body):
+ e = find_element_by_css_selector(context, '#mail-view .bodyArea')
+ assert_that(e.text, equal_to(expected_body))
+
+@then('that email has the \'{tag}\' tag')
+def impl(context, tag):
+ elements = find_elements_by_css_selector(context, '#mail-view .tagsArea .tag')
+ tags = [e.text for e in elements]
+ assert_that(tags, has_item(tag.upper()))
+
+@when('I add the tag \'{tag}\' to that mail')
+def impl(context, tag):
+ context.browser.execute_script("$('#new-tag-button').click();")
+ context.browser.execute_script("$('#new-tag-input').val('%s');" % tag)
+ e = find_element_by_css_selector(context, '#new-tag-input')
+ e.send_keys(Keys.ENTER)
+
+@then('I reply to it')
+def impl(context):
+ click_button(context, 'Reply')
+ click_button(context, 'Send')
+ context.reply_subject = reply_subject(context)
+
+@then('I see if the mail has html content')
+def impl(context):
+ e = find_element_by_css_selector(context, '#mail-view .bodyArea')
+ h2 = e.find_element_by_css_selector("h2[style*='color: #3f4944']")
+ assert_that(h2.text, contains_string('cborim'))
+
+@when('I try to delete the first mail')
+def impl(context):
+ context.execute_steps(u"When I open the first mail in the mail list")
+ find_element_by_css_selector(context, '#mail-view #view-more-actions').click()
+ context.browser.execute_script("$('#delete-button-top').click();")
+
+ e = find_element_by_css_selector(context, '#user-alerts')
+ assert_that(e.text, equal_to('Your message was moved to trash!'))
+
+@then('I choose to forward this mail')
+def impl(context):
+ wait_until_button_is_visible(context, 'Forward')
+ click_button(context, 'Forward')
+
+@then('I forward this mail')
+def impl(context):
+ wait_until_button_is_visible(context, 'Send')
+ click_button(context, 'Send')
+
+@then('I remove all tags')
+def impl(context):
+ e = find_element_by_css_selector(context, '.tagsArea')
+ tags = e.find_elements_by_css_selector('.tag')
+ assert_that(len(tags), greater_than(0))
+ for tag in tags:
+ tag.click()
+
+@then('I choose to trash')
+def impl(context):
+ wait_until_button_is_visible(context, 'Trash message')
+ click_button(context, 'Trash message')
+
+@then('I see the mail has a cc and a bcc recipient')
+def impl(context):
+ cc = find_element_by_css_selector(context, '.msg-header .cc')
+ bcc = find_element_by_css_selector(context, '.msg-header .bcc')
+
+ assert_that(cc.text, matches_regexp('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+'))
+
diff --git a/py-fake-service/features/steps/search.py b/py-fake-service/features/steps/search.py
new file mode 100644
index 00000000..f551894d
--- /dev/null
+++ b/py-fake-service/features/steps/search.py
@@ -0,0 +1,18 @@
+from selenium.webdriver.common.keys import Keys
+from behave import *
+from common import *
+from hamcrest import *
+from time import sleep
+
+@when('I search for a mail with the words "{search_term}"')
+def impl(context, search_term):
+ search_field = find_element_by_css_selector(context, '#search-trigger input[type="search"]')
+ search_field.send_keys(search_term)
+ search_field.send_keys(Keys.ENTER)
+ sleep(1)
+
+@then('I see one or more mails in the search results')
+def impl(context):
+ lis = find_elements_by_css_selector(context, '#mail-list li')
+ assert_that(len(lis), greater_than_or_equal_to(1))
+
diff --git a/py-fake-service/features/steps/tag_list.py b/py-fake-service/features/steps/tag_list.py
new file mode 100644
index 00000000..7ab84cac
--- /dev/null
+++ b/py-fake-service/features/steps/tag_list.py
@@ -0,0 +1,18 @@
+from behave import *
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
+from common import *
+
+def click_first_element_with_class(context, classname):
+ elements = context.browser.find_elements_by_class_name(classname)
+ elements[0].click()
+
+
+@when('I select the tag \'{tag}\'')
+def impl(context, tag):
+ wait_for_user_alert_to_disapear(context)
+ click_first_element_with_class(context, 'left-off-canvas-toggle')
+ context.browser.execute_script("window.scrollBy(0, -200)")
+ e = context.browser.find_element_by_xpath('//*[@id="tag-list"]/ul/li[contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "%s")]' % tag)
+ e.click()
diff --git a/py-fake-service/features/support/env.rb b/py-fake-service/features/support/env.rb
new file mode 100644
index 00000000..2386da9b
--- /dev/null
+++ b/py-fake-service/features/support/env.rb
@@ -0,0 +1,31 @@
+require 'capybara'
+require 'capybara-screenshot'
+require 'capybara-screenshot/cucumber'
+
+RACK_PORT = ENV['RACK_PORT'] || '4567'
+HOST = "http://localhost:#{RACK_PORT}"
+
+Capybara.register_driver :selenium_chrome do |app|
+ Capybara::Selenium::Driver.new(app, :browser => :firefox)
+end
+
+Capybara::Screenshot.register_driver(:selenium_chrome) do |driver, path|
+ driver.browser.save_screenshot(path)
+end
+
+driver = ENV['CUCUMBER_DRIVER'] ? ENV['CUCUMBER_DRIVER'].to_sym : :selenium_chrome
+
+Capybara.configure do |config|
+ config.run_server = false
+ config.default_driver = driver
+ config.app_host = HOST
+end
+
+include Capybara::DSL
+
+Before do
+ #{ }`curl -d '' #{HOST}/control/mailset/mediumtagged/load`
+ sleep 3
+ visit '/?lang=en'
+ page.driver.browser.manage.window.maximize
+end
diff --git a/py-fake-service/features/tag_and_reply.feature b/py-fake-service/features/tag_and_reply.feature
new file mode 100644
index 00000000..cd9c7aad
--- /dev/null
+++ b/py-fake-service/features/tag_and_reply.feature
@@ -0,0 +1,12 @@
+Feature: tagging and replying
+ Scenario: User tags a mail, replies to it then checks that mail is in the right tag
+ When I open the first mail in the 'inbox'
+ Then that email has the 'inbox' tag
+ When I add the tag 'website' to that mail
+ Then I see that mail under the 'website' tag
+ And I open the mail I previously tagged
+ And I reply to it
+ When I select the tag 'sent'
+ Then I see the mail I sent
+
+
diff --git a/py-fake-service/requirements.txt b/py-fake-service/requirements.txt
index 8f4785c6..6b253765 100644
--- a/py-fake-service/requirements.txt
+++ b/py-fake-service/requirements.txt
@@ -1,4 +1,7 @@
flask==0.10.1
scanner==0.0.5
requests==2.3.0
+PyHamcrest==1.8.0
+behave==1.2.4
+selenium==2.42.1