Skip to content

Commit 5cc5085

Browse files
intchanterAutomatedTester
authored andcommitted
Adding Python3 support, work from Isaul Vargas included in this patch
Signed-off-by: AutomatedTester <dburns@mozilla.com>
1 parent 827a065 commit 5cc5085

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+369
-361
lines changed

py/build.desc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ py_test(
4949
py_env(
5050
name = "test_env",
5151
packages = [
52-
"third_party/py/simplejson-2.2.1.tar.gz",
53-
"third_party/py/py-1.4.5.zip",
54-
"third_party/py/pytest-2.0.3.zip",
52+
"third_party/py/py-1.4.13.tar.gz",
53+
"third_party/py/pytest-2.3.4.zip",
5554
],
5655
dest = "build/python")
5756

py/docs/source/conf.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14+
from __future__ import unicode_literals
15+
1416
import sys, os, os.path
1517

1618
# If extensions (or modules to document with autodoc) are in another directory,
@@ -41,8 +43,8 @@
4143
master_doc = 'index'
4244

4345
# General information about the project.
44-
project = u'Selenium'
45-
copyright = u'2011, plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
46+
project = 'Selenium'
47+
copyright = '2011, plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
4648

4749
# The version info for the project you're documenting, acts as replacement for
4850
# |version| and |release|, also used in various other places throughout the
@@ -179,8 +181,8 @@
179181
# Grouping the document tree into LaTeX files. List of tuples
180182
# (source start file, target name, title, author, documentclass [howto/manual]).
181183
latex_documents = [
182-
('index', 'Selenium.tex', u'Selenium Documentation',
183-
u'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.', 'manual'),
184+
('index', 'Selenium.tex', 'Selenium Documentation',
185+
'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.', 'manual'),
184186
]
185187

186188
# The name of an image file (relative to this directory) to place at the top of
@@ -212,18 +214,18 @@
212214
# One entry per manual page. List of tuples
213215
# (source start file, name, description, authors, manual section).
214216
man_pages = [
215-
('index', 'selenium', u'Selenium Documentation',
216-
[u'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'], 1)
217+
('index', 'selenium', 'Selenium Documentation',
218+
['plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'], 1)
217219
]
218220

219221

220222
# -- Options for Epub output ---------------------------------------------------
221223

222224
# Bibliographic Dublin Core info.
223-
epub_title = u'Selenium'
224-
epub_author = u'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
225-
epub_publisher = u'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
226-
epub_copyright = u'2011, plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
225+
epub_title = 'Selenium'
226+
epub_author = 'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
227+
epub_publisher = 'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
228+
epub_copyright = '2011, plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'
227229

228230
# The language of the text. It defaults to the language option
229231
# or en if the language is not set.

py/selenium/common/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
import exceptions
16+
from . import exceptions

py/selenium/selenium.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,19 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
from __future__ import unicode_literals
18+
1719
__docformat__ = "restructuredtext en"
1820

19-
import httplib
20-
import urllib
21+
try:
22+
import http.client as http_client
23+
except ImportError:
24+
import httplib as http_client
25+
26+
try:
27+
import urllib.parse as urllib_parse
28+
except ImportError:
29+
import urllib as urllib_parse
2130

2231
class selenium(object):
2332
"""
@@ -190,19 +199,19 @@ def start(self, browserConfigurationOptions=None, driver=None):
190199
try:
191200
self.sessionId = result
192201
except ValueError:
193-
raise Exception, result
202+
raise Exception(result)
194203

195204
def stop(self):
196205
self.do_command("testComplete", [])
197206
self.sessionId = None
198207

199208
def do_command(self, verb, args):
200-
conn = httplib.HTTPConnection(self.host, self.port)
209+
conn = http_client.HTTPConnection(self.host, self.port)
201210
try:
202-
body = u'cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8'))
211+
body = 'cmd=' + urllib_parse.quote_plus(unicode(verb).encode('utf-8'))
203212
for i in range(len(args)):
204213
body += '&' + unicode(i+1) + '=' + \
205-
urllib.quote_plus(unicode(args[i]).encode('utf-8'))
214+
urllib_parse.quote_plus(unicode(args[i]).encode('utf-8'))
206215
if (None != self.sessionId):
207216
body += "&sessionId=" + unicode(self.sessionId)
208217
headers = {
@@ -214,7 +223,7 @@ def do_command(self, verb, args):
214223
response = conn.getresponse()
215224
data = unicode(response.read(), "UTF-8")
216225
if (not data.startswith('OK')):
217-
raise Exception, data
226+
raise Exception(data)
218227
return data
219228
finally:
220229
conn.close()
@@ -263,7 +272,7 @@ def get_boolean(self, verb, args):
263272
return True
264273
if ("false" == boolstr):
265274
return False
266-
raise ValueError, "result is neither 'true' nor 'false': " + boolstr
275+
raise ValueError("result is neither 'true' nor 'false': " + boolstr)
267276

268277
def get_boolean_array(self, verb, args):
269278
boolarr = self.get_string_array(verb, args)
@@ -274,7 +283,7 @@ def get_boolean_array(self, verb, args):
274283
if ("false" == boolstr):
275284
boolarr[i] = False
276285
continue
277-
raise ValueError, "result is neither 'true' nor 'false': " + boolarr[i]
286+
raise ValueError("result is neither 'true' nor 'false': " + boolarr[i])
278287
return boolarr
279288

280289

py/selenium/webdriver/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
from firefox.webdriver import WebDriver as Firefox
19-
from firefox.firefox_profile import FirefoxProfile
20-
from chrome.webdriver import WebDriver as Chrome
21-
from chrome.options import Options as ChromeOptions
22-
from ie.webdriver import WebDriver as Ie
23-
from opera.webdriver import WebDriver as Opera
24-
from phantomjs.webdriver import WebDriver as PhantomJS
25-
from remote.webdriver import WebDriver as Remote
26-
from common.desired_capabilities import DesiredCapabilities
27-
from common.action_chains import ActionChains
28-
from common.touch_actions import TouchActions
29-
from common.proxy import Proxy
18+
from .firefox.webdriver import WebDriver as Firefox
19+
from .firefox.firefox_profile import FirefoxProfile
20+
from .chrome.webdriver import WebDriver as Chrome
21+
from .chrome.options import Options as ChromeOptions
22+
from .ie.webdriver import WebDriver as Ie
23+
from .opera.webdriver import WebDriver as Opera
24+
from .phantomjs.webdriver import WebDriver as PhantomJS
25+
from .remote.webdriver import WebDriver as Remote
26+
from .common.desired_capabilities import DesiredCapabilities
27+
from .common.action_chains import ActionChains
28+
from .common.touch_actions import TouchActions
29+
from .common.proxy import Proxy
3030

3131
__version__ = '2.31.0'

py/selenium/webdriver/chrome/webdriver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# limitations under the License.
1616

1717
import base64
18-
import httplib
1918
from selenium.webdriver.remote.command import Command
2019
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
2120
from selenium.common.exceptions import WebDriverException
22-
from service import Service
23-
from options import Options
21+
from .service import Service
22+
from .options import Options
2423

2524
class WebDriver(RemoteWebDriver):
2625
"""

py/selenium/webdriver/common/keys.py

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,72 +13,73 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
from __future__ import unicode_literals
1617

1718
class Keys(object):
1819

19-
NULL = u'\ue000'
20-
CANCEL = u'\ue001' # ^break
21-
HELP = u'\ue002'
22-
BACK_SPACE = u'\ue003'
23-
TAB = u'\ue004'
24-
CLEAR = u'\ue005'
25-
RETURN = u'\ue006'
26-
ENTER = u'\ue007'
27-
SHIFT = u'\ue008'
28-
LEFT_SHIFT = u'\ue008' # alias
29-
CONTROL = u'\ue009'
30-
LEFT_CONTROL = u'\ue009' # alias
31-
ALT = u'\ue00a'
32-
LEFT_ALT = u'\ue00a' # alias
33-
PAUSE = u'\ue00b'
34-
ESCAPE = u'\ue00c'
35-
SPACE = u'\ue00d'
36-
PAGE_UP = u'\ue00e'
37-
PAGE_DOWN = u'\ue00f'
38-
END = u'\ue010'
39-
HOME = u'\ue011'
40-
LEFT = u'\ue012'
41-
ARROW_LEFT = u'\ue012' # alias
42-
UP = u'\ue013'
43-
ARROW_UP = u'\ue013' # alias
44-
RIGHT = u'\ue014'
45-
ARROW_RIGHT = u'\ue014' # alias
46-
DOWN = u'\ue015'
47-
ARROW_DOWN = u'\ue015' # alias
48-
INSERT = u'\ue016'
49-
DELETE = u'\ue017'
50-
SEMICOLON = u'\ue018'
51-
EQUALS = u'\ue019'
20+
NULL = '\ue000'
21+
CANCEL = '\ue001' # ^break
22+
HELP = '\ue002'
23+
BACK_SPACE = '\ue003'
24+
TAB = '\ue004'
25+
CLEAR = '\ue005'
26+
RETURN = '\ue006'
27+
ENTER = '\ue007'
28+
SHIFT = '\ue008'
29+
LEFT_SHIFT = '\ue008' # alias
30+
CONTROL = '\ue009'
31+
LEFT_CONTROL = '\ue009' # alias
32+
ALT = '\ue00a'
33+
LEFT_ALT = '\ue00a' # alias
34+
PAUSE = '\ue00b'
35+
ESCAPE = '\ue00c'
36+
SPACE = '\ue00d'
37+
PAGE_UP = '\ue00e'
38+
PAGE_DOWN = '\ue00f'
39+
END = '\ue010'
40+
HOME = '\ue011'
41+
LEFT = '\ue012'
42+
ARROW_LEFT = '\ue012' # alias
43+
UP = '\ue013'
44+
ARROW_UP = '\ue013' # alias
45+
RIGHT = '\ue014'
46+
ARROW_RIGHT = '\ue014' # alias
47+
DOWN = '\ue015'
48+
ARROW_DOWN = '\ue015' # alias
49+
INSERT = '\ue016'
50+
DELETE = '\ue017'
51+
SEMICOLON = '\ue018'
52+
EQUALS = '\ue019'
5253

53-
NUMPAD0 = u'\ue01a' # numbe pad keys
54-
NUMPAD1 = u'\ue01b'
55-
NUMPAD2 = u'\ue01c'
56-
NUMPAD3 = u'\ue01d'
57-
NUMPAD4 = u'\ue01e'
58-
NUMPAD5 = u'\ue01f'
59-
NUMPAD6 = u'\ue020'
60-
NUMPAD7 = u'\ue021'
61-
NUMPAD8 = u'\ue022'
62-
NUMPAD9 = u'\ue023'
63-
MULTIPLY = u'\ue024'
64-
ADD = u'\ue025'
65-
SEPARATOR = u'\ue026'
66-
SUBTRACT = u'\ue027'
67-
DECIMAL = u'\ue028'
68-
DIVIDE = u'\ue029'
54+
NUMPAD0 = '\ue01a' # numbe pad keys
55+
NUMPAD1 = '\ue01b'
56+
NUMPAD2 = '\ue01c'
57+
NUMPAD3 = '\ue01d'
58+
NUMPAD4 = '\ue01e'
59+
NUMPAD5 = '\ue01f'
60+
NUMPAD6 = '\ue020'
61+
NUMPAD7 = '\ue021'
62+
NUMPAD8 = '\ue022'
63+
NUMPAD9 = '\ue023'
64+
MULTIPLY = '\ue024'
65+
ADD = '\ue025'
66+
SEPARATOR = '\ue026'
67+
SUBTRACT = '\ue027'
68+
DECIMAL = '\ue028'
69+
DIVIDE = '\ue029'
6970

70-
F1 = u'\ue031' # function keys
71-
F2 = u'\ue032'
72-
F3 = u'\ue033'
73-
F4 = u'\ue034'
74-
F5 = u'\ue035'
75-
F6 = u'\ue036'
76-
F7 = u'\ue037'
77-
F8 = u'\ue038'
78-
F9 = u'\ue039'
79-
F10 = u'\ue03a'
80-
F11 = u'\ue03b'
81-
F12 = u'\ue03c'
71+
F1 = '\ue031' # function keys
72+
F2 = '\ue032'
73+
F3 = '\ue033'
74+
F4 = '\ue034'
75+
F5 = '\ue035'
76+
F6 = '\ue036'
77+
F7 = '\ue037'
78+
F8 = '\ue038'
79+
F9 = '\ue039'
80+
F10 = '\ue03a'
81+
F11 = '\ue03b'
82+
F12 = '\ue03c'
8283

83-
META = u'\ue03d'
84-
COMMAND = u'\ue03d'
84+
META = '\ue03d'
85+
COMMAND = '\ue03d'

py/selenium/webdriver/common/proxy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ class Proxy(object):
2626

2727
def __init__(self, raw=None):
2828
if raw is not None:
29-
if raw.has_key('proxyType') and raw['proxyType'] is not None:
29+
if 'proxyType' in raw and raw['proxyType'] is not None:
3030
self.proxy_type = raw['proxyType']
31-
if raw.has_key('ftpProxy') and raw['ftpProxy'] is not None:
31+
if 'ftpProxy' in raw and raw['ftpProxy'] is not None:
3232
self.ftp_proxy = raw['ftpProxy']
33-
if raw.has_key('httpProxy') and raw['httpProxy'] is not None:
33+
if 'httpProxy' in raw and raw['httpProxy'] is not None:
3434
self.http_proxy = raw['httpProxy']
35-
if raw.has_key('noProxy') and raw['noProxy'] is not None:
35+
if 'noProxy' in raw and raw['noProxy'] is not None:
3636
self.no_proxy = raw['noProxy']
37-
if raw.has_key('proxyAutoconfigUrl') and raw['proxyAutoconfigUrl'] is not None:
37+
if 'proxyAutoconfigUrl' in raw and raw['proxyAutoconfigUrl'] is not None:
3838
self.proxy_autoconfig_url = raw['proxyAutoconfigUrl']
39-
if raw.has_key('sslProxy') and raw['sslProxy'] is not None:
39+
if 'sslProxy' in raw and raw['sslProxy'] is not None:
4040
self.sslProxy = raw['sslProxy']
41-
if raw.has_key('autodetect') and raw['autodetect'] is not None:
41+
if 'autodetect' in raw and raw['autodetect'] is not None:
4242
self.auto_detect = raw['autodetect']
4343

4444
@property

0 commit comments

Comments
 (0)