Commit 2ae3baf6 authored by Kevin Sibug's avatar Kevin Sibug

Edited the code to become cleaner and added geckodriver

parent 5f2eccd8
File added
from selenium import webdriver
import unittest
import time
class NewVisitorTest(unittest.TestCase):
def setUp(self):
......@@ -19,21 +20,26 @@ class NewVisitorTest(unittest.TestCase):
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
self.assertIn('Cloud', self.browser.find_element_by_id('cloud').text)
self.assertIn('Jester', self.browser.find_element_by_id('jester').text)
self.assertIn('Sunflowey', self.browser.find_element_by_id('sunflowey').text)
self.assertIn('Health Points', self.browser.find_element_by_id('cloud').text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('cloud').text)
self.assertIn('Health Points', self.browser.find_element_by_id('jester').text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('jester').text)
self.assertIn('Health Points', self.browser.find_element_by_id('sunflowey').text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('sunflowey').text)
cloud = self.browser.find_element_by_id('cloud')
jester = self.browser.find_element_by_id('jester')
sunflowey = self.browser.find_element_by_id('sunflowey')
self.assertIn('Cloud', cloud.text)
self.assertIn('Jester', jester.text)
self.assertIn('Sunflowey', sunflowey.text)
self.assertIn('Health Points', cloud.text)
self.assertIn('Base Attack Damage', cloud.text)
self.assertIn('Health Points', jester.text)
self.assertIn('Base Attack Damage', jester.text)
self.assertIn('Health Points', sunflowey.text)
self.assertIn('Base Attack Damage', sunflowey.text)
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
link = self.browser.find_element_by_id('cloud-view')
link.click()
self.assertEquals('http://localhost:8000/hero/cloud/',self.browser.current_url)
cloud_view = self.browser.find_element_by_id('cloud-view')
cloud_view.click()
self.assertEquals('http://localhost:8000/hero/cloud/',
self.browser.current_url)
list_of_attributes = self.browser.find_elements_by_tag_name('dt')
self.assertIn('Health Points', list_of_attributes[0].text)
self.assertIn('Base Attack Damage', list_of_attributes[1].text)
......@@ -41,8 +47,16 @@ class NewVisitorTest(unittest.TestCase):
self.assertIn('Lore', list_of_attributes[3].text)
# She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Detail - Cloud', self.browser.title)
# 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.
back_to_heroes_list_button = self.browser.find_element_by_tag_name('button')
self.assertIn('Back to Heroes List', back_to_heroes_list_button.text)
back_to_heroes_list_button.click()
self.assertEquals('http://localhost:8000/heroes/',self.browser.current_url)
#time
time.sleep(5)
......
from django.contrib import admin
from django.urls import path
# from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from . import views
......@@ -13,5 +12,3 @@ urlpatterns = [
path('hero/jester/', views.JesterView.as_view(), name='jester_view'),
]
# urlpatterns += staticfiles_urlpatterns()
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class HeroesView(TemplateView):
template_name = "heroes.html"
......
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