Commit a8c5a288 authored by Kyla Villegas's avatar Kyla Villegas

Working lab1_functional_test.py

parent 55cd6b41
This diff is collapsed.
......@@ -15,7 +15,7 @@
<dt>Skills</dt><dd>Nimbus, Rain Cloud, Thunderbolt</dd>
<dt>Lore</dt><dd>I am a cloud. When I pee you call it 'rain'.</dd>
</dl>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'" >Back to Heroes List</button>
</div>
</body>
</html>
......@@ -15,7 +15,7 @@
<dt>Skills</dt><dd>Laugh, Dance, Smile</dd>
<dt>Lore</dt><dd>I do it for the LOLs.</dd>
</dl>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'" >Back to Heroes List</button>
</div>
</body>
</html>
......@@ -15,7 +15,7 @@
<dt>Skills</dt><dd>Power Pellet, Sunshine, Pollen Punch</dd>
<dt>Lore</dt><dd>I am Sunflowey. Sometimes a sun, sometimes a flower.</dd>
</dl>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'" >Back to Heroes List</button>
</div>
</body>
</html>
......@@ -8,13 +8,14 @@
<div id ="sunflowey">
<div id ="jester">
<h1>The Will of the Wisps Wiki</h1>
<a href='/hero/cloud'>Cloud</a>
<ul>
<li><a href='http://localhost:8000/hero/cloud' class="link">Cloud</a></li>
<p>Health Points: 600</p>
<p>Damage: 57</p>
<a href='/hero/sunflowey'>Sunflowey</a>
<li><a href='http://localhost:8000/hero/sunflowey' class="link">Sunflowey</a></li>
<p>Health Points: 650</p>
<p>Damage: 43</p>
<a href='/hero/jester'>Jester</a>
<li><a href='http://localhost:8000/hero/jester' class="link">Jester</a></li>
<p>Health Points: 660</p>
<p>Damage: 64</p>
</ul>
......
import unittest
import time
from selenium import webdriver
import unittest
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
......@@ -40,43 +39,44 @@ class NewVisitorTest(unittest.TestCase):
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
if cloud_link.click():
self.assertEquals('http://localhost:8000/hero/cloud/', self.browser.current_url)
elif sunflowey_link.click():
self.assertEquals('http://localhost:8000/hero/sunflowey/', self.browser.current_url)
elif jester_link.click():
self.assertEquals('http://localhost:8000/hero/jester/', self.browser.current_url)
# She spots the page title and header mentions the name of the hero she selected.
if cloud_link.click():
self.assertIn('Detail - Cloud', self.browser.title)
header_text = self.browser.find_element_by_tag_name('head') #kyla header
self.assertIn('Detail - Cloud', header_text)
elif sunflowey_link.click():
self.assertIn('Detail - Sunflowey', self.browser.title)
header_text = self.browser.find_element_by_tag_name('head') #kyla header
self.assertIn('Detail - Sunflowey', header_text)
elif jester_link.click():
self.assertIn('Detail - Jester', self.browser.title)
header_text = self.browser.find_element_by_tag_name('head') #kyla header
self.assertIn('Detail - Jester', header_text)
# 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.
while (cloud_link.click() == True or sunflowey_link.click() == True or jester_link.click() == True):
button = driver.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', button)
button.click()
time.sleep(1)
self.assertIn(browser.getCurrentUrl(), 'http://localhost:8000/heroes')
# input.send_keys('Back to Heroes List')
# input.send_keys(Keys.Enter)
# time.sleep(1)
# self.assertIn(browser.getCurrentUrl(), 'http://localhost:8000/heroes')
cloud = self.browser.find_element_by_link_text('Cloud')
cloud.click()
self.assertEqual('http://localhost:8000/hero/cloud/', self.browser.current_url)
self.assertIn('Detail - Cloud', self.browser.title)
cloud = self.browser.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', cloud.text)
cloud.click()
self.assertEqual('http://localhost:8000/heroes', self.browser.current_url)
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
sunflowey = self.browser.find_element_by_link_text('Sunflowey')
sunflowey.click()
self.assertEqual('http://localhost:8000/hero/sunflowey/', self.browser.current_url)
self.assertIn('Detail - Sunflowey', self.browser.title)
sunflowey = self.browser.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', sunflowey.text)
sunflowey.click()
self.assertEqual('http://localhost:8000/heroes', self.browser.current_url)
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
self.fail('Finish the test!')
jester = self.browser.find_element_by_link_text('Jester')
jester.click()
self.assertEqual('http://localhost:8000/hero/jester/', self.browser.current_url)
self.assertIn('Detail - Jester', self.browser.title)
jester = self.browser.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', jester.text)
jester.click()
self.assertEqual('http://localhost:8000/heroes', self.browser.current_url)
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
if __name__ == '__main__':
unittest.main(warnings='ignore')
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