Commit b517844a authored by Jay Lopez's avatar Jay Lopez

functional test completed

parent bae3e4c9
from random import randint
from selenium import webdriver from selenium import webdriver
import unittest import unittest
class NewVisitorTest(unittest.TestCase): class NewVisitorTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.browser = webdriver.Chrome() self.browser = webdriver.Chrome()
...@@ -11,7 +13,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -11,7 +13,7 @@ class NewVisitorTest(unittest.TestCase):
def test_can_display_a_heroes_list_and_more_information_per_hero(self): def test_can_display_a_heroes_list_and_more_information_per_hero(self):
# Widget has heard about a new wiki app for the game called The Will of the Wisps. # Widget has heard about a new wiki app for the game called The Will of the Wisps.
# She goes to check out its homepage # She goes to check out its homepage
self.browser.get('http://localhost:8000') self.browser.get('https://localhost:8000/heroes')
# She notices the page title and header mention # She notices the page title and header mention
# 'The Will of the Wisps Wiki' # 'The Will of the Wisps Wiki'
...@@ -19,14 +21,24 @@ class NewVisitorTest(unittest.TestCase): ...@@ -19,14 +21,24 @@ class NewVisitorTest(unittest.TestCase):
# She sees a list containing three heroes with their corresponding # She sees a list containing three heroes with their corresponding
# names, health points, and damage # names, health points, and damage
hero_list = self.browser.find_element_by_tag_name('ul')
# When she selects one of the heroes, she is sent to another page # When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image). # containing more information about the hero (additional stats, lore, image).
links = hero_list.find_elements_by_tag_name('li')
selected_hero_link = links[randint(0, 2)]
hero_name = selected_hero_link.text.split()[0]
selected_hero_link.click()
# She spots the page title and header mentions the name of the hero she selected. # She spots the page title and header mentions the name of the hero she selected.
self.assertIn(hero_name, self.browser.title)
# While she is in a specific hero's page, she sees a button labeled "Back to Heroes List". # While she is in a specific hero's page, she sees a button labeled "Back to Heroes List".
# She clicks this and she is redirected back to the wiki's homepage. # She clicks this and she is redirected back to the wiki's homepage.
home_button = self.browser.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', home_button.text)
home_button.click()
self.assertIn('/heroes', self.browser.current_url)
self.fail('Finish the test!') self.fail('Finish the test!')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment