1414from selenium .webdriver .common .action_chains import ActionChains
1515from selenium .webdriver .common .touch_actions import TouchActions
1616from selenium .webdriver .firefox .options import Options as FirefoxOptions
17- from selenium .webdriver .opera .options import Options as OperaOptions
1817from selenium .webdriver .remote .webdriver import WebDriver as RemoteWebDriver
1918from selenium .webdriver .support .ui import WebDriverWait
2019
@@ -156,13 +155,23 @@ class instanced for one browser
156155 "firefox" : DesiredCapabilities .FIREFOX .copy (),
157156 "iexplorer" : DesiredCapabilities .INTERNETEXPLORER .copy (),
158157 "edge" : DesiredCapabilities .EDGE .copy (),
159- "opera" : DesiredCapabilities .OPERA .copy (),
160158 }[browser_name ]
161159 except KeyError :
162160 msg = 'Bad browser selected at load options'
163161 raise CoreException (msg = msg , log = self .log )
164162 return capabilities
165163
164+ def __check_driver_ready__ (self , driver_path , capabilities , options ):
165+ """Some checks to ensure driver path, caps and options
166+ are ready to be used
167+ """
168+ if driver_path is None :
169+ driver_path = self .curr_driver_path
170+ if capabilities is None :
171+ capabilities = self .curr_caps
172+ if options is None :
173+ options = self .curr_options
174+
166175 def get_options (self , browser_name = 'chrome' , headless_enabled = False ):
167176 """Instance Options class from selenium and return it
168177
@@ -186,7 +195,6 @@ class instanced for one browser
186195 options = {
187196 "chrome" : ChromeOptions (),
188197 "firefox" : FirefoxOptions (),
189- "opera" : OperaOptions (),
190198 }[browser_name ]
191199 if headless_enabled :
192200 options .add_argument ("--headless" )
@@ -245,12 +253,7 @@ def get_driver_chrome(self, driver_path=None, capabilities=None,
245253 Returns:
246254 [WebDriver.Chrome] -- WebDriver opened and ready to be used
247255 """
248- if driver_path is None :
249- driver_path = self .curr_driver_path
250- if capabilities is None :
251- capabilities = self .curr_caps
252- if options is None :
253- options = self .curr_options
256+ self .__check_driver_ready__ (driver_path , capabilities , options )
254257 return WebDriver .Chrome (
255258 executable_path = driver_path ,
256259 desired_capabilities = capabilities ,
@@ -270,12 +273,7 @@ def get_driver_firefox(self, driver_path=None, capabilities=None,
270273 Returns:
271274 [WebDriver.Firefox] -- WebDriver opened and ready to be used
272275 """
273- if driver_path is None :
274- driver_path = self .curr_driver_path
275- if capabilities is None :
276- capabilities = self .curr_caps
277- if options is None :
278- options = self .curr_options
276+ self .__check_driver_ready__ (driver_path , capabilities , options )
279277 return WebDriver .Firefox (
280278 executable_path = driver_path ,
281279 capabilities = capabilities ,
@@ -293,10 +291,7 @@ def get_driver_iexplorer(self, driver_path=None, capabilities=None):
293291 Returns:
294292 [WebDriver.Ie] -- WebDriver opened and ready to be used
295293 """
296- if driver_path is None :
297- driver_path = self .curr_driver_path
298- if capabilities is None :
299- capabilities = self .curr_caps
294+ self .__check_driver_ready__ (driver_path , capabilities )
300295 return WebDriver .Ie (
301296 executable_path = driver_path ,
302297 capabilities = capabilities )
@@ -314,38 +309,11 @@ def get_driver_edge(self, driver_path=None, capabilities=None):
314309 Returns:
315310 [WebDriver.Edge] -- WebDriver opened and ready to be used
316311 """
317- if driver_path is None :
318- driver_path = self .curr_driver_path
319- if capabilities is None :
320- capabilities = self .curr_caps
312+ self .__check_driver_ready__ (driver_path , capabilities )
321313 return WebDriver .Edge (
322314 executable_path = driver_path ,
323315 capabilities = capabilities )
324316
325- def get_driver_opera (self , driver_path = None , capabilities = None ,
326- options = None ):
327- """Open WebDriver selenium based on Opera browser
328-
329- Keyword Arguments:
330- driver_path {str} -- Path for driver binary path
331- (default: {None})
332- capabilities {DesiredCapabilities} -- Capabilities for browser
333- (default: {None})
334- options {Options} -- Options for browser (default: {None})
335-
336- Returns:
337- [WebDriver.Opera] -- WebDriver opened and ready to be used
338- """
339- if driver_path is None :
340- driver_path = self .curr_driver_path
341- if capabilities is None :
342- capabilities = self .curr_caps
343- if options is None :
344- options = self .curr_options
345- return WebDriver .Opera (
346- executable_path = driver_path ,
347- capabilities = capabilities )
348-
349317 def mode_local (self , browser_name = 'chrome' ):
350318 """Open new brower on local mode
351319
@@ -366,7 +334,6 @@ def mode_local(self, browser_name='chrome'):
366334 "firefox" : self .get_driver_firefox (),
367335 "iexplorer" : self .get_driver_iexplorer (),
368336 "edge" : self .get_driver_edge (),
369- "opera" : self .get_driver_opera (),
370337 }[browser_name ]
371338 except KeyError :
372339 raise CoreException (
0 commit comments