worked on tests
This commit is contained in:
parent
3f8f30f5d1
commit
936fbf30f6
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.idea/
|
||||
tests/results/
|
||||
**.DS_Store
|
||||
**.swp
|
||||
**.pyc
|
||||
|
@ -49,8 +49,25 @@ def wait_net_service(server, port, timeout=None):
|
||||
return True
|
||||
|
||||
|
||||
class PythonOrgSearch(unittest.TestCase):
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.screen_shot_counter = 0
|
||||
self.driver = webdriver.Remote(
|
||||
command_executor='http://selenium:4444/wd/hub',
|
||||
desired_capabilities=DesiredCapabilities.FIREFOX)
|
||||
self.driver.get("http://rollerverbrauch:5000")
|
||||
WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "email")))
|
||||
|
||||
def create_screenshot(self):
|
||||
self.driver.get_screenshot_as_file(
|
||||
'/results/%s_%s_%s.png' % (self.__class__.__name__, inspect.stack()[1][3], str(self.screen_shot_counter)))
|
||||
self.screen_shot_counter += 1
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
|
||||
class RegisterCheck(BaseTestCase):
|
||||
def setUp(self):
|
||||
self.screen_shot_counter = 0
|
||||
self.driver = webdriver.Remote(
|
||||
@ -62,7 +79,7 @@ class PythonOrgSearch(unittest.TestCase):
|
||||
def test_page_loads(self):
|
||||
self.driver.get("http://rollerverbrauch:5000")
|
||||
self.create_screenshot()
|
||||
assert "refuel" in self.driver.title
|
||||
self.assertIn("refuel", self.driver.title, "Title must contain reload")
|
||||
|
||||
def test_can_register(self):
|
||||
self.driver.get("http://rollerverbrauch:5000")
|
||||
@ -84,22 +101,36 @@ class PythonOrgSearch(unittest.TestCase):
|
||||
self.create_screenshot()
|
||||
WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
|
||||
self.create_screenshot()
|
||||
self.driver.find_element_by_id('email').send_keys('test@test.com')
|
||||
self.driver.find_element_by_id('email').send_keys('test1@test.com')
|
||||
self.driver.find_element_by_id('password').send_keys('test123')
|
||||
self.create_screenshot()
|
||||
self.driver.find_element_by_id('submit').click()
|
||||
self.create_screenshot()
|
||||
error = self.driver.find_elements_by_class_name('error')
|
||||
assert error is not None
|
||||
self.assertIsNotNone(error[0], 'we expect an error')
|
||||
self.assertIn('Passwords do not match', error[0].text, 'wrong error message')
|
||||
|
||||
def create_screenshot(self):
|
||||
print(self.__class__.__name__, inspect.stack()[1][3])
|
||||
self.driver.get_screenshot_as_file('/results/%s_%s_%s.png' % (self.__class__.__name__, inspect.stack()[1][3], str(self.screen_shot_counter)))
|
||||
self.screen_shot_counter += 1
|
||||
def test_register_must_be_equal_pwd(self):
|
||||
self.driver.get("http://rollerverbrauch:5000")
|
||||
self.driver.find_element_by_partial_link_text('Register').click()
|
||||
self.create_screenshot()
|
||||
WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
|
||||
self.create_screenshot()
|
||||
self.driver.find_element_by_id('email').send_keys('test1@test.com')
|
||||
self.driver.find_element_by_id('password').send_keys('test123')
|
||||
self.driver.find_element_by_id('password_confirm').send_keys('test1234')
|
||||
self.create_screenshot()
|
||||
self.driver.find_element_by_id('submit').click()
|
||||
self.create_screenshot()
|
||||
error = self.driver.find_elements_by_class_name('error')
|
||||
self.assertIsNotNone(error[0], 'we expect an error')
|
||||
self.assertIn('Passwords do not match', error[0].text, 'wrong error message')
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
class LoginCheck(BaseTestCase):
|
||||
|
||||
def can_login(self):
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
wait_net_service('selenium', 4444)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 38 KiB |
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -f results/*
|
||||
docker-compose build
|
||||
docker-compose up --abort-on-container-exit
|
||||
docker-compose down
|
||||
|
Loading…
Reference in New Issue
Block a user