From 352126b4173ea51411a4bcf13cccc51d3dde7d8a Mon Sep 17 00:00:00 2001 From: Will Daly Date: Fri, 8 Mar 2013 10:08:20 -0500 Subject: [PATCH 01/15] Updated tests for correct_map to match changes made to get_npoints --- common/lib/capa/capa/tests/test_correctmap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/capa/capa/tests/test_correctmap.py b/common/lib/capa/capa/tests/test_correctmap.py index 23734467bb..270ba4d849 100644 --- a/common/lib/capa/capa/tests/test_correctmap.py +++ b/common/lib/capa/capa/tests/test_correctmap.py @@ -91,12 +91,12 @@ class CorrectMapTest(unittest.TestCase): npoints=0) # Assert that we get the expected points - # If points assigned and correct --> npoints + # If points assigned --> npoints # If no points assigned and correct --> 1 point - # Otherwise --> 0 points + # If no points assigned and incorrect --> 0 points self.assertEqual(self.cmap.get_npoints('1_2_1'), 5) self.assertEqual(self.cmap.get_npoints('2_2_1'), 1) - self.assertEqual(self.cmap.get_npoints('3_2_1'), 0) + self.assertEqual(self.cmap.get_npoints('3_2_1'), 5) self.assertEqual(self.cmap.get_npoints('4_2_1'), 0) self.assertEqual(self.cmap.get_npoints('5_2_1'), 0) From a44c0932d288e3112baf2a35a5400dd03ac60f49 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Mar 2013 10:08:39 -0500 Subject: [PATCH 02/15] Fix https://edx.lighthouseapp.com/projects/101932-lms/tickets/237-Production-500-error-for-undefined-variable-user --- lms/djangoapps/courseware/module_render.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 23d27c72ac..ec2178f642 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -500,7 +500,7 @@ def modx_dispatch(request, dispatch, location, course_id): if instance is None: # Either permissions just changed, or someone is trying to be clever # and load something they shouldn't have access to. - log.debug("No module {0} for user {1}--access denied?".format(location, user)) + log.debug("No module {0} for user {1}--access denied?".format(location, request.user)) raise Http404 instance_module = get_instance_module(course_id, request.user, instance, student_module_cache) From cd802d8e142697736114739fcb735534346ce544 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Mar 2013 10:36:59 -0500 Subject: [PATCH 03/15] Add datadog metrics capture around heartbeat timing --- cms/envs/aws.py | 3 +++ cms/one_time_startup.py | 6 ++++++ cms/urls.py | 1 + common/djangoapps/heartbeat/views.py | 3 ++- .../student/management/commands/pearson_transfer.py | 1 + lms/one_time_startup.py | 6 ++++++ lms/urls.py | 3 +++ 7 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cms/one_time_startup.py create mode 100644 lms/one_time_startup.py diff --git a/cms/envs/aws.py b/cms/envs/aws.py index a147f84531..be7816d21f 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -62,3 +62,6 @@ AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"] DATABASES = AUTH_TOKENS['DATABASES'] MODULESTORE = AUTH_TOKENS['MODULESTORE'] CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE'] + +# Datadog for events! +DATADOG_API = AUTH_TOKENS.get("DATADOG_API") \ No newline at end of file diff --git a/cms/one_time_startup.py b/cms/one_time_startup.py new file mode 100644 index 0000000000..93428a3404 --- /dev/null +++ b/cms/one_time_startup.py @@ -0,0 +1,6 @@ +from dogapi import dog_http_api, dog_stats_api +from django.conf import settings + +if hasattr(settings, 'DATADOG_API'): + dog_http_api.api_key = settings.DATADOG_API + dog_stats_api.start(api_key=settings.DATADOG_API, statsd=True) diff --git a/cms/urls.py b/cms/urls.py index 7b7b5e9375..d43b9bc44c 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -1,5 +1,6 @@ from django.conf import settings from django.conf.urls import patterns, include, url +from . import one_time_startup # Uncomment the next two lines to enable the admin: # from django.contrib import admin diff --git a/common/djangoapps/heartbeat/views.py b/common/djangoapps/heartbeat/views.py index 956504407b..d7c3a32192 100644 --- a/common/djangoapps/heartbeat/views.py +++ b/common/djangoapps/heartbeat/views.py @@ -2,8 +2,9 @@ import json from datetime import datetime from django.http import HttpResponse from xmodule.modulestore.django import modulestore +from dogapi import dog_stats_api - +@dog_stats_api.timed('edxapp.heartbeat') def heartbeat(request): """ Simple view that a loadbalancer can check to verify that the app is up diff --git a/common/djangoapps/student/management/commands/pearson_transfer.py b/common/djangoapps/student/management/commands/pearson_transfer.py index 5eded6484a..75716c7443 100644 --- a/common/djangoapps/student/management/commands/pearson_transfer.py +++ b/common/djangoapps/student/management/commands/pearson_transfer.py @@ -10,6 +10,7 @@ import paramiko import boto dog_http_api.api_key = settings.DATADOG_API +dog_stats_api.start(api_key=settings.DATADOG_API, statsd=True) class Command(BaseCommand): diff --git a/lms/one_time_startup.py b/lms/one_time_startup.py new file mode 100644 index 0000000000..93428a3404 --- /dev/null +++ b/lms/one_time_startup.py @@ -0,0 +1,6 @@ +from dogapi import dog_http_api, dog_stats_api +from django.conf import settings + +if hasattr(settings, 'DATADOG_API'): + dog_http_api.api_key = settings.DATADOG_API + dog_stats_api.start(api_key=settings.DATADOG_API, statsd=True) diff --git a/lms/urls.py b/lms/urls.py index 5972b49266..f2ec45f402 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -3,6 +3,9 @@ from django.conf.urls import patterns, include, url from django.contrib import admin from django.conf.urls.static import static from django.views.generic import RedirectView + +from . import one_time_startup + import django.contrib.auth.views # Uncomment the next two lines to enable the admin: From ae610aebaa69c5192c0cd5034d2bbfe7855f6920 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Mar 2013 10:48:55 -0500 Subject: [PATCH 04/15] Set the dogapi version --- github-requirements.txt | 1 - requirements.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/github-requirements.txt b/github-requirements.txt index 62e47a328f..468d55ce65 100644 --- a/github-requirements.txt +++ b/github-requirements.txt @@ -3,4 +3,3 @@ -e git://github.com/MITx/django-pipeline.git#egg=django-pipeline -e git://github.com/MITx/django-wiki.git@e2e84558#egg=django-wiki -e git://github.com/dementrock/pystache_custom.git@776973740bdaad83a3b029f96e415a7d1e8bec2f#egg=pystache_custom-dev --e git://github.com/MITx/dogapi.git@003a4fc9#egg=dogapi diff --git a/requirements.txt b/requirements.txt index 07cd2f767b..204ec85889 100644 --- a/requirements.txt +++ b/requirements.txt @@ -58,3 +58,4 @@ ipython==0.13.1 xmltodict==0.4.1 paramiko==1.9.0 Pillow==1.7.8 +dogapi==1.2.1 From b9e5ed9525d102304eb72499875596a5bca4234e Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Mon, 4 Mar 2013 15:35:09 -0500 Subject: [PATCH 05/15] Click in the upper left of an element instead of the middle. --- cms/djangoapps/contentstore/features/common.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index 61b4fee9f6..3ad037b5a9 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -94,8 +94,11 @@ def assert_css_with_text(css, text): def css_click(css): - assert_true(world.browser.is_element_present_by_css(css, 5)) - world.browser.find_by_css(css).first.click() + ''' + Rather than click in the middle of an element, + click in the upper left + ''' + css_click_at(css) def css_click_at(css, x=10, y=10): From 3cec8f1a76e10c914b0b863fb26e1e53ff7bdd6c Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Mon, 4 Mar 2013 15:50:25 -0500 Subject: [PATCH 06/15] Catch WebDriverException --- .../contentstore/features/advanced-settings.py | 7 ++++++- cms/djangoapps/contentstore/features/common.py | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/features/advanced-settings.py b/cms/djangoapps/contentstore/features/advanced-settings.py index 91daf70718..4ce9421ad3 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.py +++ b/cms/djangoapps/contentstore/features/advanced-settings.py @@ -1,6 +1,7 @@ from lettuce import world, step from common import * import time +from selenium.common.exceptions import WebDriverException from nose.tools import assert_equal from nose.tools import assert_true @@ -42,7 +43,11 @@ def edit_the_name_of_a_policy_key(step): @step(u'I press the "([^"]*)" notification button$') def press_the_notification_button(step, name): - world.browser.click_link_by_text(name) + try: + world.browser.click_link_by_text(name) + except WebDriverException, e: + css = 'a.%s-button' % name.lower() + css_click_at(css) @step(u'I edit the value of a policy key$') diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index 3ad037b5a9..a8da3dc2eb 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -3,6 +3,7 @@ from lettuce.django import django_url from nose.tools import assert_true from nose.tools import assert_equal from selenium.webdriver.support.ui import WebDriverWait +from selenium.common.exceptions import WebDriverException from terrain.factories import UserFactory, RegistrationFactory, UserProfileFactory from terrain.factories import CourseFactory, GroupFactory @@ -95,10 +96,16 @@ def assert_css_with_text(css, text): def css_click(css): ''' - Rather than click in the middle of an element, - click in the upper left + First try to use the regular click method, + but if clicking in the middle of an element + doesn't work it might be that it thinks some other + element is on top of it there so click in the upper left ''' - css_click_at(css) + 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) def css_click_at(css, x=10, y=10): From 21c15d8f1f480e88eed443f5c0a152158388c1b2 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Mon, 4 Mar 2013 15:35:09 -0500 Subject: [PATCH 07/15] Click in the upper left of an element instead of the middle. --- cms/djangoapps/contentstore/features/common.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index a8da3dc2eb..e374f240b9 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -96,6 +96,7 @@ def assert_css_with_text(css, text): def css_click(css): ''' +<<<<<<< HEAD First try to use the regular click method, but if clicking in the middle of an element doesn't work it might be that it thinks some other @@ -106,6 +107,12 @@ def css_click(css): world.browser.find_by_css(css).first.click() except WebDriverException, e: 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. def css_click_at(css, x=10, y=10): From e84fa6382661b0eb71754425bd2e747386212abf Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Mon, 4 Mar 2013 15:50:25 -0500 Subject: [PATCH 08/15] Catch WebDriverException --- cms/djangoapps/contentstore/features/common.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index e374f240b9..b5c42436e2 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -97,10 +97,14 @@ def assert_css_with_text(css, text): def css_click(css): ''' <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Catch WebDriverException First try to use the regular click method, but if clicking in the middle of an element doesn't work it might be that it thinks some other element is on top of it there so click in the upper left +<<<<<<< HEAD ''' try: assert_true(world.browser.is_element_present_by_css(css, 5)) @@ -113,6 +117,14 @@ def css_click(css): ''' 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): From ad5d2a9624a954efc6fe85d7fdd15ff1e4bd0aa0 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Tue, 5 Mar 2013 14:32:06 -0500 Subject: [PATCH 09/15] Update update_templates reference --- cms/djangoapps/contentstore/features/common.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index b5c42436e2..b6e2b2b429 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -7,7 +7,8 @@ from selenium.common.exceptions import WebDriverException from terrain.factories import UserFactory, RegistrationFactory, UserProfileFactory from terrain.factories import CourseFactory, GroupFactory -import xmodule.modulestore.django +from xmodule.modulestore.django import _MODULESTORES, modulestore +from xmodule.templates import update_templates from auth.authz import get_user_by_email from logging import getLogger @@ -84,9 +85,9 @@ def flush_xmodule_store(): # (though it shouldn't), do this manually # from the bash shell to drop it: # $ mongo test_xmodule --eval "db.dropDatabase()" - xmodule.modulestore.django._MODULESTORES = {} - xmodule.modulestore.django.modulestore().collection.drop() - xmodule.templates.update_templates() + _MODULESTORES = {} + modulestore().collection.drop() + update_templates() def assert_css_with_text(css, text): From b66d0cf5da7f7da951de85f841678d51d09c5d79 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Tue, 5 Mar 2013 17:15:17 -0500 Subject: [PATCH 10/15] Fix signup test on ubuntu --- cms/djangoapps/contentstore/features/signup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/features/signup.py b/cms/djangoapps/contentstore/features/signup.py index a786225ead..e8d0dd8229 100644 --- a/cms/djangoapps/contentstore/features/signup.py +++ b/cms/djangoapps/contentstore/features/signup.py @@ -1,4 +1,5 @@ from lettuce import world, step +from common import * @step('I fill in the registration form$') @@ -13,10 +14,11 @@ def i_fill_in_the_registration_form(step): @step('I press the Create My Account button on the registration form$') def i_press_the_button_on_the_registration_form(step): - register_form = world.browser.find_by_css('form#register_form') - submit_css = 'button#submit' - register_form.find_by_css(submit_css).click() - + submit_css = 'form#register_form button#submit' + # Workaround for click not working on ubuntu + # for some unknown reason. + e = css_find(submit_css) + e.type(' ') @step('I should see be on the studio home page$') def i_should_see_be_on_the_studio_home_page(step): From 21e7bc5128b42c54b204cf7558aff65889850d11 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Thu, 7 Mar 2013 11:01:15 -0500 Subject: [PATCH 11/15] More robust handling for finding and clicking on objects by css. Tag tests not working under PhantomJS to skip for now. --- .gitignore | 3 +- .../features/advanced-settings.feature | 3 + .../features/advanced-settings.py | 59 +++++++++++-------- .../contentstore/features/common.py | 41 ++++--------- .../contentstore/features/section.feature | 1 + .../studio-overview-togglesection.feature | 1 + .../contentstore/features/subsection.feature | 1 + common/djangoapps/terrain/browser.py | 3 +- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index 493df5a7fd..b13a128a63 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ nosetests.xml cover_html/ .idea/ .redcar/ -chromedriver.log \ No newline at end of file +chromedriver.log +ghostdriver.log diff --git a/cms/djangoapps/contentstore/features/advanced-settings.feature b/cms/djangoapps/contentstore/features/advanced-settings.feature index 4708a60be1..779d44e4b2 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.feature +++ b/cms/djangoapps/contentstore/features/advanced-settings.feature @@ -7,6 +7,7 @@ Feature: Advanced (manual) course policy When I select the Advanced Settings Then I see only the display name + @skip-phantom Scenario: Test if there are no policy settings without existing UI controls Given I am on the Advanced Course Settings page in Studio When I delete the display name @@ -14,6 +15,7 @@ Feature: Advanced (manual) course policy And I reload the page Then there are no advanced policy settings + @skip-phantom Scenario: Test cancel editing key name Given I am on the Advanced Course Settings page in Studio When I edit the name of a policy key @@ -32,6 +34,7 @@ Feature: Advanced (manual) course policy And I press the "Cancel" notification button Then the policy key value is unchanged + @skip-phantom Scenario: Test editing key value Given I am on the Advanced Course Settings page in Studio When I edit the value of a policy key diff --git a/cms/djangoapps/contentstore/features/advanced-settings.py b/cms/djangoapps/contentstore/features/advanced-settings.py index 4ce9421ad3..dbbe769b8e 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.py +++ b/cms/djangoapps/contentstore/features/advanced-settings.py @@ -2,9 +2,9 @@ from lettuce import world, step from common import * import time 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 +from nose.tools import assert_true, assert_false, assert_equal """ 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): css_click(expand_icon_css) link_css = 'li.nav-course-settings-advanced a' css_click(link_css) + # world.browser.click_link_by_text('Advanced Settings') @step('I am on the Advanced Course Settings page in Studio$') @@ -43,12 +44,20 @@ def edit_the_name_of_a_policy_key(step): @step(u'I press the "([^"]*)" notification button$') def press_the_notification_button(step, name): - try: - world.browser.click_link_by_text(name) - except WebDriverException, e: - css = 'a.%s-button' % name.lower() - css_click_at(css) + 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: + css_click_at(css) + wait_for(is_invisible) + except WebDriverException, e: + css_click_at(css) + wait_for(is_invisible) @step(u'I edit the value of a policy key$') def edit_the_value_of_a_policy_key(step): @@ -104,29 +113,29 @@ def it_is_formatted(step): @step(u'the policy key name is unchanged$') def the_policy_key_name_is_unchanged(step): policy_key_css = 'input.policy-key' - e = css_find(policy_key_css).first - assert_equal(e.value, 'display_name') + val = css_find(policy_key_css).first.value + assert_equal(val, 'display_name') @step(u'the policy key name is changed$') def the_policy_key_name_is_changed(step): policy_key_css = 'input.policy-key' - e = css_find(policy_key_css).first - assert_equal(e.value, 'new') + val = css_find(policy_key_css).first.value + assert_equal(val, 'new') @step(u'the policy key value is unchanged$') def the_policy_key_value_is_unchanged(step): policy_value_css = 'li.course-advanced-policy-list-item div.value textarea' - e = css_find(policy_value_css).first - assert_equal(e.value, '"Robot Super Course"') + val = css_find(policy_value_css).first.value + assert_equal(val, '"Robot Super Course"') @step(u'the policy key value is changed$') def the_policy_key_value_is_unchanged(step): policy_value_css = 'li.course-advanced-policy-list-item div.value textarea' - e = css_find(policy_value_css).first - assert_equal(e.value, '"Robot Super Course X"') + val = css_find(policy_value_css).first.value + assert_equal(val, '"Robot Super Course X"') ############# HELPERS ############### @@ -149,7 +158,7 @@ def delete_entry(index): """ 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)) delete_buttons = css_find(css) assert_true(len(delete_buttons) > index, "no delete button exists for entry " + str(index)) @@ -170,16 +179,16 @@ def assert_entries(css, expected_values): def click_save(): - css = ".save-button" + css = "a.save-button" - def is_shown(driver): - visible = css_find(css).first.visible - if visible: - # Even when waiting for visible, this fails sporadically. Adding in a small wait. - time.sleep(float(1)) - return visible - wait_for(is_shown) - css_click(css) + # def is_shown(driver): + # visible = css_find(css).first.visible + # if visible: + # # Even when waiting for visible, this fails sporadically. Adding in a small wait. + # time.sleep(float(1)) + # return visible + # wait_for(is_shown) + css_click_at(css) def fill_last_field(value): diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index b6e2b2b429..f7e76ecf7f 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -3,7 +3,9 @@ from lettuce.django import django_url from nose.tools import assert_true from nose.tools import assert_equal 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 CourseFactory, GroupFactory @@ -15,8 +17,6 @@ from logging import getLogger logger = getLogger(__name__) ########### STEP HELPERS ############## - - @step('I (?:visit|access|open) the Studio homepage$') def i_visit_the_studio_homepage(step): # To make this go to port 8001, put @@ -54,9 +54,8 @@ def i_have_opened_a_new_course(step): log_into_studio() create_a_course() + ####### HELPER FUNCTIONS ############## - - def create_studio_user( uname='robot', email='robot+studio@edx.org', @@ -97,35 +96,15 @@ def assert_css_with_text(css, text): def css_click(css): ''' -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> Catch WebDriverException First try to use the regular click method, but if clicking in the middle of an element doesn't work it might be that it thinks some other element is on top of it there so click in the upper left -<<<<<<< HEAD ''' try: - assert_true(world.browser.is_element_present_by_css(css, 5)) - world.browser.find_by_css(css).first.click() + css_find(css).first.click() except WebDriverException, e: 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): @@ -133,8 +112,7 @@ def css_click_at(css, x=10, y=10): A method to click at x,y coordinates of the element rather than in the center of the element ''' - assert_true(world.browser.is_element_present_by_css(css, 5)) - e = world.browser.find_by_css(css).first + e = css_find(css).first e.action_chains.move_to_element_with_offset(e._element, x, y) e.action_chains.click() e.action_chains.perform() @@ -145,11 +123,16 @@ def css_fill(css, value): 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) def wait_for(func): - WebDriverWait(world.browser.driver, 10).until(func) + WebDriverWait(world.browser.driver, 5).until(func) def id_find(id): diff --git a/cms/djangoapps/contentstore/features/section.feature b/cms/djangoapps/contentstore/features/section.feature index 75e7a4af10..93ff1ca247 100644 --- a/cms/djangoapps/contentstore/features/section.feature +++ b/cms/djangoapps/contentstore/features/section.feature @@ -26,6 +26,7 @@ Feature: Create Section And I save a new section release date Then the section release date is updated + @skip-phantom Scenario: Delete section Given I have opened a new course in Studio And I have added a new section diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature index 5276b90d12..52c10e41a8 100644 --- a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature @@ -21,6 +21,7 @@ Feature: Overview Toggle Section Then I see the "Collapse All Sections" link And all sections are expanded + @skip-phantom Scenario: Collapse link is not removed after last section of a course is deleted Given I have a course with 1 section And I navigate to the course overview page diff --git a/cms/djangoapps/contentstore/features/subsection.feature b/cms/djangoapps/contentstore/features/subsection.feature index 4b5f5b869d..1be5f4aeb9 100644 --- a/cms/djangoapps/contentstore/features/subsection.feature +++ b/cms/djangoapps/contentstore/features/subsection.feature @@ -17,6 +17,7 @@ Feature: Create Subsection And I click to edit the subsection name Then I see the complete subsection name with a quote in the editor + @skip-phantom Scenario: Delete a subsection Given I have opened a new course section in Studio And I have added a new subsection diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index 8c2a8ba7a5..ddd39196de 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -12,7 +12,8 @@ from django.core.management import call_command @before.harvest def initial_setup(server): # 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') From 1f30baabfd1f45e2bfde56ee35e2b4f281a1aa85 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Thu, 7 Mar 2013 11:23:58 -0500 Subject: [PATCH 12/15] Change default browser for lettuce back to chrome. --- common/djangoapps/terrain/browser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index ddd39196de..0881d86124 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -12,8 +12,8 @@ from django.core.management import call_command @before.harvest def initial_setup(server): # Launch the browser app (choose one of these below) - # world.browser = Browser('chrome') - world.browser = Browser('phantomjs') + world.browser = Browser('chrome') + # world.browser = Browser('phantomjs') # world.browser = Browser('firefox') From 24d088933e022a101f6a3ed5bfa7f8280d2996f5 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Thu, 7 Mar 2013 11:37:34 -0500 Subject: [PATCH 13/15] Fix intermittent lettuce test failure on ubuntu. --- cms/djangoapps/contentstore/features/advanced-settings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/features/advanced-settings.py b/cms/djangoapps/contentstore/features/advanced-settings.py index dbbe769b8e..ec58aeccc6 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.py +++ b/cms/djangoapps/contentstore/features/advanced-settings.py @@ -146,12 +146,16 @@ def create_entry(key, value): new_key_css = 'div#__new_advanced_key__ input' new_key_element = css_find(new_key_css).first new_key_element.fill(key) -# For some reason have to get the instance for each command (get error that it is no longer attached to the DOM) -# Have to do all this because Selenium has a bug that fill does not remove existing text +# For some reason have to get the instance for each command +# (get error that it is no longer attached to the DOM) +# Have to do all this because Selenium fill does not remove existing text new_value_css = 'div.CodeMirror textarea' css_find(new_value_css).last.fill("") css_find(new_value_css).last._element.send_keys(Keys.DELETE, Keys.DELETE) css_find(new_value_css).last.fill(value) + # Add in a TAB key press because intermittently on ubuntu the + # last character of "value" above was not getting typed in + css_find(new_value_css).last._element.send_keys(Keys.TAB) def delete_entry(index): From 55eefd0ef6ba8230ad2e5d8944c28238fbc93ce8 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Fri, 8 Mar 2013 11:11:32 -0500 Subject: [PATCH 14/15] Fix test that sets release date to work on all platforms --- .../contentstore/features/section.feature | 2 +- cms/djangoapps/contentstore/features/section.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/features/section.feature b/cms/djangoapps/contentstore/features/section.feature index 93ff1ca247..08d38367bc 100644 --- a/cms/djangoapps/contentstore/features/section.feature +++ b/cms/djangoapps/contentstore/features/section.feature @@ -32,4 +32,4 @@ Feature: Create Section And I have added a new section When I press the "section" delete icon And I confirm the alert - Then the section does not exist \ No newline at end of file + Then the section does not exist diff --git a/cms/djangoapps/contentstore/features/section.py b/cms/djangoapps/contentstore/features/section.py index cfa4e4bb52..b5ddb48a09 100644 --- a/cms/djangoapps/contentstore/features/section.py +++ b/cms/djangoapps/contentstore/features/section.py @@ -1,6 +1,8 @@ from lettuce import world, step from common import * from nose.tools import assert_equal +from selenium.webdriver.common.keys import Keys +import time ############### ACTIONS #################### @@ -37,10 +39,14 @@ def i_save_a_new_section_release_date(step): date_css = 'input.start-date.date.hasDatepicker' time_css = 'input.start-time.time.ui-timepicker-input' css_fill(date_css, '12/25/2013') - # click here to make the calendar go away - css_click(time_css) + # hit TAB to get to the time field + e = css_find(date_css).first + e._element.send_keys(Keys.TAB) css_fill(time_css, '12:00am') - css_click('a.save-button') + e = css_find(time_css).first + e._element.send_keys(Keys.TAB) + time.sleep(float(1)) + world.browser.click_link_by_text('Save') ############ ASSERTIONS ################### @@ -106,7 +112,7 @@ def the_section_release_date_picker_not_visible(step): def the_section_release_date_is_updated(step): css = 'span.published-status' status_text = world.browser.find_by_css(css).text - assert status_text == 'Will Release: 12/25/2013 at 12:00am' + assert_equal(status_text,'Will Release: 12/25/2013 at 12:00am') ############ HELPER METHODS ################### @@ -120,4 +126,4 @@ def save_section_name(name): def see_my_section_on_the_courseware_page(name): section_css = 'span.section-name-span' - assert_css_with_text(section_css, name) \ No newline at end of file + assert_css_with_text(section_css, name) From fab07597d264c6845b4dda08f8857c36c407a8ce Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 8 Mar 2013 11:59:02 -0500 Subject: [PATCH 15/15] Use https to talk to rubygems --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 43a9f6e2b1..7f7b146978 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source :rubygems +source 'https://rubygems.org' gem 'rake', '~> 10.0.3' gem 'sass', '3.1.15' gem 'bourbon', '~> 1.3.6'