Skip to content

Commit 6b2dac2

Browse files
author
Cleverson Sampaio
committed
feat(browser): added browser class to support webdriver-manager
added browser class support for drivers like chrome, chromium, brave, firefox, ie, edge and opera
1 parent 9fcd42b commit 6b2dac2

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"commit": "cz",
88
"install": "python setup.py install",
9-
"uninstall": "pip uninstall seleniumlibraryextends -y"
9+
"uninstall": "pip uninstall seleniumlibraryextends -y",
10+
"build": "npm run uninstall && npm run install"
1011
},
1112
"repository": {
1213
"type": "git",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Diretório do seu pacote
3333
package_dir = {'': 'src'},
3434
# Dependências/outros módulos necessários para o seu pacote funcionar
35-
install_requires = ['robotframework', 'robotframework-seleniumlibrary'],
35+
install_requires = ['robotframework', 'robotframework-seleniumlibrary', 'webdriver-manager'],
3636
# Descrição detalhada do seu pacote
3737
long_description = 'Selenium library keyword extension to support Behavior Driven Development',
3838
# Formato da sua descrição detalhada

src/SeleniumLibraryExtends/Navigation/navigation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from robot.libraries.BuiltIn import BuiltIn
77
from robot.api.deco import keyword
88
from SeleniumLibraryExtends.report import Report
9+
from SeleniumLibraryExtends.browser import Browser
910

1011
class Navigation:
1112
def __init__(self):
@@ -14,7 +15,7 @@ def __init__(self):
1415
@keyword("I open the browser ${browser}")
1516
def openBrowser(self, browser: str, maximize: bool = True):
1617
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
17-
self.driver.open_browser("about:blank", browser)
18+
self.driver.open_browser("about:blank", browser, None, None, None, None, None, None, Browser().path(browser))
1819
if maximize:
1920
self.driver.maximize_browser_window()
2021

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2022 Cléverson Sampaio <cleverson@sampaio.dev.br>
5+
6+
from webdriver_manager.opera import OperaDriverManager
7+
from webdriver_manager.microsoft import EdgeChromiumDriverManager
8+
from webdriver_manager.microsoft import IEDriverManager
9+
from webdriver_manager.firefox import GeckoDriverManager
10+
from webdriver_manager.chrome import ChromeDriverManager
11+
from webdriver_manager.core.utils import ChromeType
12+
13+
class Browser:
14+
def __init__(self):
15+
pass
16+
17+
def path(self, browser: str) -> str:
18+
if browser == "chrome":
19+
return ChromeDriverManager().install()
20+
if browser == "chromium":
21+
return ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()
22+
if browser == "brave":
23+
return ChromeDriverManager(chrome_type=ChromeType.BRAVE).install()
24+
if browser == "firefox":
25+
return GeckoDriverManager().install()
26+
if browser == "ie":
27+
return IEDriverManager().install()
28+
if browser == "edge":
29+
return EdgeChromiumDriverManager().install()
30+
if browser == "opera":
31+
return OperaDriverManager().install()

0 commit comments

Comments
 (0)