1
1
#!/usr/bin/python
2
- #
3
- # Copyright 2011-2013 Sofware freedom conservancy
2
+
3
+ # Copyright 2011-2015 Sofware Freedom Conservancy
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
20
20
import httplib as http_client
21
21
22
22
import os
23
+
23
24
from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
24
25
from selenium .webdriver .remote .webdriver import WebDriver as RemoteWebDriver
25
26
from selenium .webdriver .chrome .webdriver import WebDriver as ChromiumDriver
28
29
29
30
30
31
class OperaDriver (ChromiumDriver ):
31
- """
32
- Controls the new OperaDriver and allows you
33
- to drive the Opera browser based on Chromium.
34
- """
32
+ """Controls the new OperaDriver and allows you
33
+ to drive the Opera browser based on Chromium."""
35
34
36
35
def __init__ (self , executable_path = None , port = 0 ,
37
36
opera_options = None , service_args = None ,
@@ -65,59 +64,8 @@ def create_options(self):
65
64
return Options ()
66
65
67
66
68
- class PrestoDriver (RemoteWebDriver ):
69
- """
70
- Controls the OperaDriver and allows you to drive the Opera browser
71
- based on Presto.
72
- """
73
-
74
- def __init__ (self , executable_path = None , port = 0 ,
75
- desired_capabilities = DesiredCapabilities .OPERA ):
76
- """
77
- Creates a new instance of the Opera driver.
78
-
79
- Starts the service and then creates new instance of Opera Driver.
80
-
81
- :Args:
82
- - executable_path - path to the executable. If the default is used
83
- it assumes the executable is in the
84
- Environment Variable SELENIUM_SERVER_JAR
85
- - port - port you would like the service to run, if left as 0,
86
- a free port will be found.
87
- - desired_capabilities: Dictionary object with desired capabilities -
88
- may be used to provide various Opera switches.
89
- """
90
- if executable_path is None :
91
- try :
92
- executable_path = os .environ ["SELENIUM_SERVER_JAR" ]
93
- except :
94
- raise Exception ("No executable path given, please add one \
95
- to Environment Variable 'SELENIUM_SERVER_JAR'" )
96
- self .service = Service (executable_path , port = port )
97
- self .service .start ()
98
-
99
- RemoteWebDriver .__init__ (self ,
100
- command_executor = self .service .service_url ,
101
- desired_capabilities = desired_capabilities )
102
- self ._is_remote = False
103
-
104
- def quit (self ):
105
- """
106
- Closes the browser and shuts down the OperaDriver executable
107
- that is started when starting the OperaDriver
108
- """
109
- try :
110
- RemoteWebDriver .quit (self )
111
- except http_client .BadStatusLine :
112
- pass
113
- finally :
114
- self .service .stop ()
115
-
116
-
117
- class WebDriver (PrestoDriver , OperaDriver ):
118
-
67
+ class WebDriver (OperaDriver ):
119
68
class ServiceType :
120
- PRESTO = 1
121
69
CHROMIUM = 2
122
70
123
71
def __init__ (self ,
@@ -127,27 +75,8 @@ def __init__(self,
127
75
service_log_path = None ,
128
76
service_args = None ,
129
77
opera_options = None ):
130
- engine = (desired_capabilities .get ('engine' , None )
131
- if desired_capabilities else None )
132
- if (engine == WebDriver .ServiceType .CHROMIUM or
133
- opera_options and opera_options .android_package_name ):
134
- OperaDriver .__init__ (self , executable_path = executable_path ,
135
- port = port , opera_options = opera_options ,
136
- service_args = service_args ,
137
- desired_capabilities = desired_capabilities ,
138
- service_log_path = service_log_path )
139
- else :
140
- if service_log_path :
141
- print ("Warning! service_log_path shouldn't be used " +
142
- "with Presto based Opera" )
143
- if service_args :
144
- print ("Warning! service_args shouldn't be used with " +
145
- "Presto based Opera" )
146
- if opera_options :
147
- print ("Warning! opera_options shouldn't be used with " +
148
- "Presto based Opera" )
149
- if not desired_capabilities :
150
- desired_capabilities = DesiredCapabilities .OPERA
151
- PrestoDriver .__init__ (self , executable_path = executable_path ,
152
- port = port ,
153
- desired_capabilities = desired_capabilities )
78
+ OperaDriver .__init__ (self , executable_path = executable_path ,
79
+ port = port , opera_options = opera_options ,
80
+ service_args = service_args ,
81
+ desired_capabilities = desired_capabilities ,
82
+ service_log_path = service_log_path )
0 commit comments