annotate _ui_tests/test_subitems.py @ 2936:cd48671a0488

Fixes Language Translation Issue
author Aabhas Majumdar <majumdaraabhas@gmail.com>
date Tue, 10 Mar 2015 00:42:12 +0530
parents 384555088cab
children
rev   line source
1782
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
1 # Copyright: 2012 MoinMoin:HughPerkins
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
2 # License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
3
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
4 """Functional test: create subitem"""
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1783
diff changeset
5
1782
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
6 import config
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
7 import utils
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
8
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
9
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
10 class TestSubitems(object):
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
11 """Functional test: create subitem"""
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
12
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
13 def setup_class(self):
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
14 """opens browser and creates some random item names for these tests"""
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
15 self.driver = utils.create_browser()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
16 self.base_url = config.BASE_URL
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
17 self.base_item_name = u"page_" + utils.generate_random_word(5)
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
18 self.subitem_name = u"subitem_" + utils.generate_random_word(5)
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
19
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
20 def create_wiki_item(self, item_name):
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
21 """Creates a new wiki item with name 'item_name'"""
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
22 driver = self.driver
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
23
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
24 driver.get(self.base_url + u"/" + item_name)
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
25 driver.find_element_by_link_text(u"Default").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
26 driver.find_element_by_link_text(u"Wiki (MoinMoin)").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
27 driver.find_element_by_link_text(
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
28 u"create the item from scratch").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
29 driver.find_element_by_id("f_content_form_data_text").send_keys(
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
30 u"This is a test item\n")
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
31 driver.find_element_by_id("f_submit").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
32
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
33 def test_createsubitem(self):
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
34 """Test create subitem"""
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
35 driver = self.driver
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
36
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
37 self.create_wiki_item(self.base_item_name)
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
38
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
39 driver.get(self.base_url + u"/" + self.base_item_name)
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
40 driver.find_element_by_link_text(u"Modify").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
41 driver.find_element_by_id(u"f_content_form_data_text").send_keys(
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
42 u"\n[[/" + self.subitem_name + "]]\n")
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
43 driver.find_element_by_id(u"f_submit").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
44 driver.find_element_by_link_text(u"/" + self.subitem_name).click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
45 driver.find_element_by_link_text(u"Default").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
46 driver.find_element_by_link_text(u"Wiki (MoinMoin)").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
47 driver.find_element_by_link_text(u"create the item from scratch").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
48 driver.find_element_by_id(u"f_content_form_data_text").send_keys(
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
49 u"This is a test subitem")
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
50 driver.find_element_by_id(u"f_submit").click()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
51 assert u"This is a test subitem" in driver.find_element_by_id(
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
52 u"moin-content-data").text
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
53 assert driver.title.split(u" - ")[0] == self.base_item_name + \
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
54 u"/" + self.subitem_name
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
55
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
56 def teardown_class(self):
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
57 """shuts down browser"""
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
58 self.driver.quit()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
59
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
60 if __name__ == u'__main__':
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
61 # This lets us run the test directly, without using py.test
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
62 # This is useful for example for being able to call help, eg
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
63 # 'help(driver)', or 'help(driver.find_element_by_id("f_submit"))'
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
64 testSubitems = TestSubitems()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
65 testSubitems.setup_class()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
66 testSubitems.test_createsubitem()
f87d2e646c60 created a first selenium test, specifically of adding subitems
Hugh Perkins <hughperkins@gmail.com>
parents:
diff changeset
67 testSubitems.teardown_class()