Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CSCI40 Lab Activity 1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kevin Daniel Sibug
CSCI40 Lab Activity 1
Commits
2ae3baf6
Commit
2ae3baf6
authored
Mar 07, 2020
by
Kevin Sibug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edited the code to become cleaner and added geckodriver
parent
5f2eccd8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
17 deletions
+28
-17
geckodriver.exe
geckodriver.exe
+0
-0
lab1_functional_test.py
lab1_functional_test.py
+27
-13
urls.py
willowisp/heroes/urls.py
+0
-3
views.py
willowisp/heroes/views.py
+1
-1
No files found.
geckodriver.exe
0 → 100644
View file @
2ae3baf6
File added
lab1_functional_test.py
View file @
2ae3baf6
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
)
...
...
willowisp/heroes/urls.py
View file @
2ae3baf6
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
willowisp/heroes/views.py
View file @
2ae3baf6
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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment