Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/gsutil/boto/tests/mturk/selenium_support.py

Issue 12317103: Added gsutil to depot tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added readme Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gsutil/boto/tests/mturk/selenium_support.py
diff --git a/third_party/gsutil/boto/tests/mturk/selenium_support.py b/third_party/gsutil/boto/tests/mturk/selenium_support.py
new file mode 100644
index 0000000000000000000000000000000000000000..f1552cb22741950639949ba75f9d74ab05782ff3
--- /dev/null
+++ b/third_party/gsutil/boto/tests/mturk/selenium_support.py
@@ -0,0 +1,61 @@
+from __future__ import absolute_import
+from boto.mturk.test.support import unittest
+
+sel_args = ('localhost', 4444, '*chrome', 'https://workersandbox.mturk.com')
+
+class SeleniumFailed(object):
+ def __init__(self, message):
+ self.message = message
+ def __nonzero__(self):
+ return False
+
+def has_selenium():
+ try:
+ from selenium import selenium
+ globals().update(selenium=selenium)
+ sel = selenium(*sel_args)
+ # a little trick to see if the server is responding
+ try:
+ sel.do_command('shutdown', '')
+ except Exception, e:
+ if not 'Server Exception' in str(e):
+ raise
+ result = True
+ except ImportError:
+ result = SeleniumFailed('selenium RC not installed')
+ except Exception:
+ msg = 'Error occurred initializing selenium: %s' % e
+ result = SeleniumFailed(msg)
+
+ # overwrite has_selenium, so the same result is returned every time
+ globals().update(has_selenium=lambda: result)
+ return result
+
+identity = lambda x: x
+
+def skip_unless_has_selenium():
+ res = has_selenium()
+ if not res:
+ return unittest.skip(res.message)
+ return identity
+
+def complete_hit(hit_type_id, response='Some Response'):
+ verificationErrors = []
+ sel = selenium(*sel_args)
+ sel.start()
+ sel.open("/mturk/welcome")
+ sel.click("lnkWorkerSignin")
+ sel.wait_for_page_to_load("30000")
+ sel.type("email", "boto.tester@example.com")
+ sel.type("password", "BotoTest")
+ sel.click("Continue")
+ sel.wait_for_page_to_load("30000")
+ sel.open("/mturk/preview?groupId={hit_type_id}".format(**vars()))
+ sel.click("/accept")
+ sel.wait_for_page_to_load("30000")
+ sel.type("Answer_1_FreeText", response)
+ sel.click("//div[5]/table/tbody/tr[2]/td[1]/input")
+ sel.wait_for_page_to_load("30000")
+ sel.click("link=Sign Out")
+ sel.wait_for_page_to_load("30000")
+ sel.stop()

Powered by Google App Engine
This is Rietveld 408576698