Commit 3f5b829d by clytwynec

Merge pull request #5147 from edx/clytwynec/auto_capture_har_on_error

enable auto-capturing of hars in bok-choy tests
parents 1a7009ec 4b5b72a3
from contextlib import contextmanager from contextlib import contextmanager
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise from bok_choy.promise import EmptyPromise, Promise
from .course_page import CoursePage from .course_page import CoursePage
...@@ -348,7 +348,16 @@ class DiscussionUserProfilePage(CoursePage): ...@@ -348,7 +348,16 @@ class DiscussionUserProfilePage(CoursePage):
return [elem.get_attribute("id")[7:] for elem in elems] return [elem.get_attribute("id")[7:] for elem in elems]
def get_current_page(self): def get_current_page(self):
return int(self.q(css="nav.discussion-paginator li.current-page").text[0]) def check_func():
try:
current_page = int(self.q(css="nav.discussion-paginator li.current-page").text[0])
except:
return False, None
return True, current_page
return Promise(
check_func, 'discussion-paginator current page has text', timeout=5,
).fulfill()
def _check_pager(self, text, page_number=None): def _check_pager(self, text, page_number=None):
""" """
......
""" """
Single page performance tests for Studio. Single page performance tests for Studio.
""" """
from bok_choy.performance import WebAppPerfReport, with_cache from bok_choy.web_app_test import WebAppTest, with_cache
from ..pages.studio.auto_auth import AutoAuthPage from ..pages.studio.auto_auth import AutoAuthPage
from ..pages.studio.overview import CourseOutlinePage from ..pages.studio.overview import CourseOutlinePage
from nose.plugins.attrib import attr
@attr(har_mode='explicit')
class StudioPagePerformanceTest(WebAppPerfReport): class StudioPagePerformanceTest(WebAppTest):
""" """
Base class to capture studio performance with HTTP Archives. Base class to capture studio performance with HTTP Archives.
...@@ -33,9 +34,9 @@ class StudioPagePerformanceTest(WebAppPerfReport): ...@@ -33,9 +34,9 @@ class StudioPagePerformanceTest(WebAppPerfReport):
org=self.course_org, org=self.course_org,
course=self.course_num course=self.course_num
) )
self.new_page(har_name) self.har_capturer.add_page(self.browser, har_name)
course_outline_page.visit() course_outline_page.visit()
self.save_har(har_name) self.har_capturer.save_har(self.browser, har_name)
def record_visit_unit(self, section_title, subsection_title, unit_title): def record_visit_unit(self, section_title, subsection_title, unit_title):
""" """
...@@ -47,9 +48,9 @@ class StudioPagePerformanceTest(WebAppPerfReport): ...@@ -47,9 +48,9 @@ class StudioPagePerformanceTest(WebAppPerfReport):
org=self.course_org, org=self.course_org,
course=self.course_num course=self.course_num
) )
self.new_page(har_name) self.har_capturer.add_page(self.browser, har_name)
course_outline_unit.go_to() course_outline_unit.go_to()
self.save_har(har_name) self.har_capturer.save_har(self.browser, har_name)
class StudioJusticePerformanceTest(StudioPagePerformanceTest): class StudioJusticePerformanceTest(StudioPagePerformanceTest):
......
...@@ -40,10 +40,7 @@ class BokChoyTestSuite(TestSuite): ...@@ -40,10 +40,7 @@ class BokChoyTestSuite(TestSuite):
# Ensure that we have a directory to put logs and reports # Ensure that we have a directory to put logs and reports
self.log_dir.makedirs_p() self.log_dir.makedirs_p()
self.har_dir.makedirs_p()
if self.ptests:
self.har_dir.makedirs_p()
self.report_dir.makedirs_p() self.report_dir.makedirs_p()
test_utils.clean_reports_dir() test_utils.clean_reports_dir()
...@@ -113,7 +110,7 @@ class BokChoyTestSuite(TestSuite): ...@@ -113,7 +110,7 @@ class BokChoyTestSuite(TestSuite):
cmd = [ cmd = [
"DEFAULT_STORE={}".format(self.default_store), "DEFAULT_STORE={}".format(self.default_store),
"SCREENSHOT_DIR='{}'".format(self.log_dir), "SCREENSHOT_DIR='{}'".format(self.log_dir),
"HAR_DIR='{}'".format(self.har_dir), "BOK_CHOY_HAR_DIR='{}'".format(self.har_dir),
"SELENIUM_DRIVER_LOG_DIR='{}'".format(self.log_dir), "SELENIUM_DRIVER_LOG_DIR='{}'".format(self.log_dir),
"nosetests", "nosetests",
test_spec, test_spec,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
-e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool -e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool
-e git+https://github.com/edx/event-tracking.git@0.1.0#egg=event-tracking -e git+https://github.com/edx/event-tracking.git@0.1.0#egg=event-tracking
-e git+https://github.com/edx/edx-analytics-data-api-client.git@0.1.0#egg=edx-analytics-data-api-client -e git+https://github.com/edx/edx-analytics-data-api-client.git@0.1.0#egg=edx-analytics-data-api-client
-e git+https://github.com/edx/bok-choy.git@2e6eab960a97fe41778292fe8e1b2f0b69a1be2d#egg=bok_choy -e git+https://github.com/edx/bok-choy.git@4a259e3548a19e41cc39433caf68ea58d10a27ba#egg=bok_choy
-e git+https://github.com/edx-solutions/django-splash.git@7579d052afcf474ece1239153cffe1c89935bc4f#egg=django-splash -e git+https://github.com/edx-solutions/django-splash.git@7579d052afcf474ece1239153cffe1c89935bc4f#egg=django-splash
-e git+https://github.com/edx/acid-block.git@459aff7b63db8f2c5decd1755706c1a64fb4ebb1#egg=acid-xblock -e git+https://github.com/edx/acid-block.git@459aff7b63db8f2c5decd1755706c1a64fb4ebb1#egg=acid-xblock
-e git+https://github.com/edx/edx-ora2.git@release-2014-09-12T14.26#egg=edx-ora2 -e git+https://github.com/edx/edx-ora2.git@release-2014-09-12T14.26#egg=edx-ora2
......
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