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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 from __future__ import absolute_import
2 from boto.mturk.test.support import unittest
3
4 sel_args = ('localhost', 4444, '*chrome', 'https://workersandbox.mturk.com')
5
6 class SeleniumFailed(object):
7 def __init__(self, message):
8 self.message = message
9 def __nonzero__(self):
10 return False
11
12 def has_selenium():
13 try:
14 from selenium import selenium
15 globals().update(selenium=selenium)
16 sel = selenium(*sel_args)
17 # a little trick to see if the server is responding
18 try:
19 sel.do_command('shutdown', '')
20 except Exception, e:
21 if not 'Server Exception' in str(e):
22 raise
23 result = True
24 except ImportError:
25 result = SeleniumFailed('selenium RC not installed')
26 except Exception:
27 msg = 'Error occurred initializing selenium: %s' % e
28 result = SeleniumFailed(msg)
29
30 # overwrite has_selenium, so the same result is returned every time
31 globals().update(has_selenium=lambda: result)
32 return result
33
34 identity = lambda x: x
35
36 def skip_unless_has_selenium():
37 res = has_selenium()
38 if not res:
39 return unittest.skip(res.message)
40 return identity
41
42 def complete_hit(hit_type_id, response='Some Response'):
43 verificationErrors = []
44 sel = selenium(*sel_args)
45 sel.start()
46 sel.open("/mturk/welcome")
47 sel.click("lnkWorkerSignin")
48 sel.wait_for_page_to_load("30000")
49 sel.type("email", "boto.tester@example.com")
50 sel.type("password", "BotoTest")
51 sel.click("Continue")
52 sel.wait_for_page_to_load("30000")
53 sel.open("/mturk/preview?groupId={hit_type_id}".format(**vars()))
54 sel.click("/accept")
55 sel.wait_for_page_to_load("30000")
56 sel.type("Answer_1_FreeText", response)
57 sel.click("//div[5]/table/tbody/tr[2]/td[1]/input")
58 sel.wait_for_page_to_load("30000")
59 sel.click("link=Sign Out")
60 sel.wait_for_page_to_load("30000")
61 sel.stop()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698