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 from selenium import webdriver
import unittest import unittest
import time
class NewVisitorTest(unittest.TestCase): class NewVisitorTest(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -19,21 +20,26 @@ class NewVisitorTest(unittest.TestCase): ...@@ -19,21 +20,26 @@ 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
self.assertIn('Cloud', self.browser.find_element_by_id('cloud').text)
self.assertIn('Jester', self.browser.find_element_by_id('jester').text) cloud = self.browser.find_element_by_id('cloud')
self.assertIn('Sunflowey', self.browser.find_element_by_id('sunflowey').text) jester = self.browser.find_element_by_id('jester')
self.assertIn('Health Points', self.browser.find_element_by_id('cloud').text) sunflowey = self.browser.find_element_by_id('sunflowey')
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('cloud').text) self.assertIn('Cloud', cloud.text)
self.assertIn('Health Points', self.browser.find_element_by_id('jester').text) self.assertIn('Jester', jester.text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('jester').text) self.assertIn('Sunflowey', sunflowey.text)
self.assertIn('Health Points', self.browser.find_element_by_id('sunflowey').text) self.assertIn('Health Points', cloud.text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('sunflowey').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 # 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).
link = self.browser.find_element_by_id('cloud-view') cloud_view = self.browser.find_element_by_id('cloud-view')
link.click() cloud_view.click()
self.assertEquals('http://localhost:8000/hero/cloud/',self.browser.current_url) self.assertEquals('http://localhost:8000/hero/cloud/',
self.browser.current_url)
list_of_attributes = self.browser.find_elements_by_tag_name('dt') list_of_attributes = self.browser.find_elements_by_tag_name('dt')
self.assertIn('Health Points', list_of_attributes[0].text) self.assertIn('Health Points', list_of_attributes[0].text)
self.assertIn('Base Attack Damage', list_of_attributes[1].text) self.assertIn('Base Attack Damage', list_of_attributes[1].text)
...@@ -41,8 +47,16 @@ class NewVisitorTest(unittest.TestCase): ...@@ -41,8 +47,16 @@ class NewVisitorTest(unittest.TestCase):
self.assertIn('Lore', list_of_attributes[3].text) self.assertIn('Lore', list_of_attributes[3].text)
# 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('Detail - Cloud', self.browser.title) 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". # 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.contrib import admin
from django.urls import path from django.urls import path
# from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from . import views from . import views
...@@ -13,5 +12,3 @@ urlpatterns = [ ...@@ -13,5 +12,3 @@ urlpatterns = [
path('hero/jester/', views.JesterView.as_view(), name='jester_view'), 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.shortcuts import render
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
# Create your views here.
class HeroesView(TemplateView): class HeroesView(TemplateView):
template_name = "heroes.html" 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