Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
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
edx
edx-platform
Commits
21e7bc51
Commit
21e7bc51
authored
Mar 07, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More robust handling for finding and clicking on objects by css.
Tag tests not working under PhantomJS to skip for now.
parent
b66d0cf5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
56 deletions
+55
-56
.gitignore
+2
-2
cms/djangoapps/contentstore/features/advanced-settings.feature
+3
-0
cms/djangoapps/contentstore/features/advanced-settings.py
+33
-24
cms/djangoapps/contentstore/features/common.py
+12
-29
cms/djangoapps/contentstore/features/section.feature
+1
-0
cms/djangoapps/contentstore/features/studio-overview-togglesection.feature
+1
-0
cms/djangoapps/contentstore/features/subsection.feature
+1
-0
common/djangoapps/terrain/browser.py
+2
-1
No files found.
.gitignore
View file @
21e7bc51
...
@@ -28,4 +28,5 @@ nosetests.xml
...
@@ -28,4 +28,5 @@ nosetests.xml
cover_html/
cover_html/
.idea/
.idea/
.redcar/
.redcar/
chromedriver.log
chromedriver.log
\ No newline at end of file
ghostdriver.log
cms/djangoapps/contentstore/features/advanced-settings.feature
View file @
21e7bc51
...
@@ -7,6 +7,7 @@ Feature: Advanced (manual) course policy
...
@@ -7,6 +7,7 @@ Feature: Advanced (manual) course policy
When
I select the Advanced Settings
When
I select the Advanced Settings
Then
I see only the display name
Then
I see only the display name
@skip-phantom
Scenario
:
Test if there are no policy settings without existing UI controls
Scenario
:
Test if there are no policy settings without existing UI controls
Given
I am on the Advanced Course Settings page in Studio
Given
I am on the Advanced Course Settings page in Studio
When
I delete the display name
When
I delete the display name
...
@@ -14,6 +15,7 @@ Feature: Advanced (manual) course policy
...
@@ -14,6 +15,7 @@ Feature: Advanced (manual) course policy
And
I reload the page
And
I reload the page
Then
there are no advanced policy settings
Then
there are no advanced policy settings
@skip-phantom
Scenario
:
Test cancel editing key name
Scenario
:
Test cancel editing key name
Given
I am on the Advanced Course Settings page in Studio
Given
I am on the Advanced Course Settings page in Studio
When
I edit the name of a policy key
When
I edit the name of a policy key
...
@@ -32,6 +34,7 @@ Feature: Advanced (manual) course policy
...
@@ -32,6 +34,7 @@ Feature: Advanced (manual) course policy
And
I press the
"Cancel"
notification button
And
I press the
"Cancel"
notification button
Then
the policy key value is unchanged
Then
the policy key value is unchanged
@skip-phantom
Scenario
:
Test editing key value
Scenario
:
Test editing key value
Given
I am on the Advanced Course Settings page in Studio
Given
I am on the Advanced Course Settings page in Studio
When
I edit the value of a policy key
When
I edit the value of a policy key
...
...
cms/djangoapps/contentstore/features/advanced-settings.py
View file @
21e7bc51
...
@@ -2,9 +2,9 @@ from lettuce import world, step
...
@@ -2,9 +2,9 @@ from lettuce import world, step
from
common
import
*
from
common
import
*
import
time
import
time
from
selenium.common.exceptions
import
WebDriverException
from
selenium.common.exceptions
import
WebDriverException
from
selenium.webdriver.support
import
expected_conditions
as
EC
from
nose.tools
import
assert_equal
from
nose.tools
import
assert_true
,
assert_false
,
assert_equal
from
nose.tools
import
assert_true
"""
"""
http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html
http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html
...
@@ -20,6 +20,7 @@ def i_select_advanced_settings(step):
...
@@ -20,6 +20,7 @@ def i_select_advanced_settings(step):
css_click
(
expand_icon_css
)
css_click
(
expand_icon_css
)
link_css
=
'li.nav-course-settings-advanced a'
link_css
=
'li.nav-course-settings-advanced a'
css_click
(
link_css
)
css_click
(
link_css
)
# world.browser.click_link_by_text('Advanced Settings')
@step
(
'I am on the Advanced Course Settings page in Studio$'
)
@step
(
'I am on the Advanced Course Settings page in Studio$'
)
...
@@ -43,12 +44,20 @@ def edit_the_name_of_a_policy_key(step):
...
@@ -43,12 +44,20 @@ def edit_the_name_of_a_policy_key(step):
@step
(
u'I press the "([^"]*)" notification button$'
)
@step
(
u'I press the "([^"]*)" notification button$'
)
def
press_the_notification_button
(
step
,
name
):
def
press_the_notification_button
(
step
,
name
):
def
is_visible
(
driver
):
return
EC
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
css
,))
def
is_invisible
(
driver
):
return
EC
.
invisibility_of_element_located
((
By
.
CSS_SELECTOR
,
css
,))
css
=
'a.
%
s-button'
%
name
.
lower
()
wait_for
(
is_visible
)
try
:
try
:
world
.
browser
.
click_link_by_text
(
name
)
css_click_at
(
css
)
wait_for
(
is_invisible
)
except
WebDriverException
,
e
:
except
WebDriverException
,
e
:
css
=
'a.
%
s-button'
%
name
.
lower
()
css_click_at
(
css
)
css_click_at
(
css
)
wait_for
(
is_invisible
)
@step
(
u'I edit the value of a policy key$'
)
@step
(
u'I edit the value of a policy key$'
)
def
edit_the_value_of_a_policy_key
(
step
):
def
edit_the_value_of_a_policy_key
(
step
):
...
@@ -104,29 +113,29 @@ def it_is_formatted(step):
...
@@ -104,29 +113,29 @@ def it_is_formatted(step):
@step
(
u'the policy key name is unchanged$'
)
@step
(
u'the policy key name is unchanged$'
)
def
the_policy_key_name_is_unchanged
(
step
):
def
the_policy_key_name_is_unchanged
(
step
):
policy_key_css
=
'input.policy-key'
policy_key_css
=
'input.policy-key'
e
=
css_find
(
policy_key_css
)
.
first
val
=
css_find
(
policy_key_css
)
.
first
.
value
assert_equal
(
e
.
value
,
'display_name'
)
assert_equal
(
val
,
'display_name'
)
@step
(
u'the policy key name is changed$'
)
@step
(
u'the policy key name is changed$'
)
def
the_policy_key_name_is_changed
(
step
):
def
the_policy_key_name_is_changed
(
step
):
policy_key_css
=
'input.policy-key'
policy_key_css
=
'input.policy-key'
e
=
css_find
(
policy_key_css
)
.
first
val
=
css_find
(
policy_key_css
)
.
first
.
value
assert_equal
(
e
.
value
,
'new'
)
assert_equal
(
val
,
'new'
)
@step
(
u'the policy key value is unchanged$'
)
@step
(
u'the policy key value is unchanged$'
)
def
the_policy_key_value_is_unchanged
(
step
):
def
the_policy_key_value_is_unchanged
(
step
):
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
e
=
css_find
(
policy_value_css
)
.
first
val
=
css_find
(
policy_value_css
)
.
first
.
value
assert_equal
(
e
.
value
,
'"Robot Super Course"'
)
assert_equal
(
val
,
'"Robot Super Course"'
)
@step
(
u'the policy key value is changed$'
)
@step
(
u'the policy key value is changed$'
)
def
the_policy_key_value_is_unchanged
(
step
):
def
the_policy_key_value_is_unchanged
(
step
):
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
e
=
css_find
(
policy_value_css
)
.
first
val
=
css_find
(
policy_value_css
)
.
first
.
value
assert_equal
(
e
.
value
,
'"Robot Super Course X"'
)
assert_equal
(
val
,
'"Robot Super Course X"'
)
############# HELPERS ###############
############# HELPERS ###############
...
@@ -149,7 +158,7 @@ def delete_entry(index):
...
@@ -149,7 +158,7 @@ def delete_entry(index):
"""
"""
Delete the nth entry where index is 0-based
Delete the nth entry where index is 0-based
"""
"""
css
=
'.delete-button'
css
=
'
a
.delete-button'
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
delete_buttons
=
css_find
(
css
)
delete_buttons
=
css_find
(
css
)
assert_true
(
len
(
delete_buttons
)
>
index
,
"no delete button exists for entry "
+
str
(
index
))
assert_true
(
len
(
delete_buttons
)
>
index
,
"no delete button exists for entry "
+
str
(
index
))
...
@@ -170,16 +179,16 @@ def assert_entries(css, expected_values):
...
@@ -170,16 +179,16 @@ def assert_entries(css, expected_values):
def
click_save
():
def
click_save
():
css
=
".save-button"
css
=
"
a
.save-button"
def
is_shown
(
driver
):
#
def is_shown(driver):
visible
=
css_find
(
css
)
.
first
.
visible
#
visible = css_find(css).first.visible
if
visible
:
#
if visible:
# Even when waiting for visible, this fails sporadically. Adding in a small wait.
#
# Even when waiting for visible, this fails sporadically. Adding in a small wait.
time
.
sleep
(
float
(
1
))
#
time.sleep(float(1))
return
visible
#
return visible
wait_for
(
is_shown
)
#
wait_for(is_shown)
css_click
(
css
)
css_click
_at
(
css
)
def
fill_last_field
(
value
):
def
fill_last_field
(
value
):
...
...
cms/djangoapps/contentstore/features/common.py
View file @
21e7bc51
...
@@ -3,7 +3,9 @@ from lettuce.django import django_url
...
@@ -3,7 +3,9 @@ from lettuce.django import django_url
from
nose.tools
import
assert_true
from
nose.tools
import
assert_true
from
nose.tools
import
assert_equal
from
nose.tools
import
assert_equal
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.common.exceptions
import
WebDriverException
from
selenium.common.exceptions
import
WebDriverException
,
StaleElementReferenceException
from
selenium.webdriver.support
import
expected_conditions
as
EC
from
selenium.webdriver.common.by
import
By
from
terrain.factories
import
UserFactory
,
RegistrationFactory
,
UserProfileFactory
from
terrain.factories
import
UserFactory
,
RegistrationFactory
,
UserProfileFactory
from
terrain.factories
import
CourseFactory
,
GroupFactory
from
terrain.factories
import
CourseFactory
,
GroupFactory
...
@@ -15,8 +17,6 @@ from logging import getLogger
...
@@ -15,8 +17,6 @@ from logging import getLogger
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
########### STEP HELPERS ##############
########### STEP HELPERS ##############
@step
(
'I (?:visit|access|open) the Studio homepage$'
)
@step
(
'I (?:visit|access|open) the Studio homepage$'
)
def
i_visit_the_studio_homepage
(
step
):
def
i_visit_the_studio_homepage
(
step
):
# To make this go to port 8001, put
# To make this go to port 8001, put
...
@@ -54,9 +54,8 @@ def i_have_opened_a_new_course(step):
...
@@ -54,9 +54,8 @@ def i_have_opened_a_new_course(step):
log_into_studio
()
log_into_studio
()
create_a_course
()
create_a_course
()
####### HELPER FUNCTIONS ##############
####### HELPER FUNCTIONS ##############
def
create_studio_user
(
def
create_studio_user
(
uname
=
'robot'
,
uname
=
'robot'
,
email
=
'robot+studio@edx.org'
,
email
=
'robot+studio@edx.org'
,
...
@@ -97,35 +96,15 @@ def assert_css_with_text(css, text):
...
@@ -97,35 +96,15 @@ def assert_css_with_text(css, text):
def
css_click
(
css
):
def
css_click
(
css
):
'''
'''
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> Catch WebDriverException
First try to use the regular click method,
First try to use the regular click method,
but if clicking in the middle of an element
but if clicking in the middle of an element
doesn't work it might be that it thinks some other
doesn't work it might be that it thinks some other
element is on top of it there so click in the upper left
element is on top of it there so click in the upper left
<<<<<<< HEAD
'''
'''
try
:
try
:
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
css_find
(
css
)
.
first
.
click
()
world
.
browser
.
find_by_css
(
css
)
.
first
.
click
()
except
WebDriverException
,
e
:
except
WebDriverException
,
e
:
css_click_at
(
css
)
css_click_at
(
css
)
=======
Rather
than
click
in
the
middle
of
an
element
,
click
in
the
upper
left
'''
css_click_at(css)
>>>>>>> Click in the upper left of an element instead of the middle.
=======
'''
try
:
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
world
.
browser
.
find_by_css
(
css
)
.
first
.
click
()
except
WebDriverException
,
e
:
css_click_at
(
css
)
>>>>>>>
Catch
WebDriverException
def
css_click_at
(
css
,
x
=
10
,
y
=
10
):
def
css_click_at
(
css
,
x
=
10
,
y
=
10
):
...
@@ -133,8 +112,7 @@ def css_click_at(css, x=10, y=10):
...
@@ -133,8 +112,7 @@ def css_click_at(css, x=10, y=10):
A method to click at x,y coordinates of the element
A method to click at x,y coordinates of the element
rather than in the center of the element
rather than in the center of the element
'''
'''
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
e
=
css_find
(
css
)
.
first
e
=
world
.
browser
.
find_by_css
(
css
)
.
first
e
.
action_chains
.
move_to_element_with_offset
(
e
.
_element
,
x
,
y
)
e
.
action_chains
.
move_to_element_with_offset
(
e
.
_element
,
x
,
y
)
e
.
action_chains
.
click
()
e
.
action_chains
.
click
()
e
.
action_chains
.
perform
()
e
.
action_chains
.
perform
()
...
@@ -145,11 +123,16 @@ def css_fill(css, value):
...
@@ -145,11 +123,16 @@ def css_fill(css, value):
def
css_find
(
css
):
def
css_find
(
css
):
def
is_visible
(
driver
):
return
EC
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
css
,))
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
wait_for
(
is_visible
)
return
world
.
browser
.
find_by_css
(
css
)
return
world
.
browser
.
find_by_css
(
css
)
def
wait_for
(
func
):
def
wait_for
(
func
):
WebDriverWait
(
world
.
browser
.
driver
,
10
)
.
until
(
func
)
WebDriverWait
(
world
.
browser
.
driver
,
5
)
.
until
(
func
)
def
id_find
(
id
):
def
id_find
(
id
):
...
...
cms/djangoapps/contentstore/features/section.feature
View file @
21e7bc51
...
@@ -26,6 +26,7 @@ Feature: Create Section
...
@@ -26,6 +26,7 @@ Feature: Create Section
And
I save a new section release date
And
I save a new section release date
Then
the section release date is updated
Then
the section release date is updated
@skip-phantom
Scenario
:
Delete section
Scenario
:
Delete section
Given
I have opened a new course in Studio
Given
I have opened a new course in Studio
And
I have added a new section
And
I have added a new section
...
...
cms/djangoapps/contentstore/features/studio-overview-togglesection.feature
View file @
21e7bc51
...
@@ -21,6 +21,7 @@ Feature: Overview Toggle Section
...
@@ -21,6 +21,7 @@ Feature: Overview Toggle Section
Then
I see the
"Collapse All Sections"
link
Then
I see the
"Collapse All Sections"
link
And
all sections are expanded
And
all sections are expanded
@skip-phantom
Scenario
:
Collapse link is not removed after last section of a course is deleted
Scenario
:
Collapse link is not removed after last section of a course is deleted
Given
I have a course with 1 section
Given
I have a course with 1 section
And
I navigate to the course overview page
And
I navigate to the course overview page
...
...
cms/djangoapps/contentstore/features/subsection.feature
View file @
21e7bc51
...
@@ -17,6 +17,7 @@ Feature: Create Subsection
...
@@ -17,6 +17,7 @@ Feature: Create Subsection
And
I click to edit the subsection name
And
I click to edit the subsection name
Then
I see the complete subsection name with a quote in the editor
Then
I see the complete subsection name with a quote in the editor
@skip-phantom
Scenario
:
Delete a subsection
Scenario
:
Delete a subsection
Given
I have opened a new course section in Studio
Given
I have opened a new course section in Studio
And
I have added a new subsection
And
I have added a new subsection
...
...
common/djangoapps/terrain/browser.py
View file @
21e7bc51
...
@@ -12,7 +12,8 @@ from django.core.management import call_command
...
@@ -12,7 +12,8 @@ from django.core.management import call_command
@before.harvest
@before.harvest
def
initial_setup
(
server
):
def
initial_setup
(
server
):
# Launch the browser app (choose one of these below)
# Launch the browser app (choose one of these below)
world
.
browser
=
Browser
(
'chrome'
)
# world.browser = Browser('chrome')
world
.
browser
=
Browser
(
'phantomjs'
)
# world.browser = Browser('firefox')
# world.browser = Browser('firefox')
...
...
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