Skip to content

Commit b6b9ca3

Browse files
authored
Merge pull request #45 from lf2a/ie-support
ENH: IE support
2 parents e363131 + 9bb118b commit b6b9ca3

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

botcity/web/browsers/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from . import chrome
44
from . import firefox
55
from . import edge
6+
from . import ie
67

78

89
class Browser(str, enum.Enum):
@@ -13,10 +14,12 @@ class Browser(str, enum.Enum):
1314
CHROME (str): Google Chrome
1415
FIREFOX (str): Mozilla Firefox
1516
EDGE (str): Microsoft Edge
17+
IE (str): Microsoft Internet Explorer
1618
"""
1719
CHROME = "chrome"
1820
FIREFOX = "firefox"
1921
EDGE = "edge"
22+
IE = "ie"
2023

2124

2225
BROWSER_CONFIGS = {
@@ -41,4 +44,11 @@ class Browser(str, enum.Enum):
4144
"capabilities": edge.default_capabilities,
4245
"wait_for_downloads": edge.wait_for_downloads
4346
},
47+
Browser.IE: {
48+
"driver": "IEDriverServer",
49+
"class": ie.Ie,
50+
"options": ie.default_options,
51+
"capabilities": ie.default_capabilities,
52+
"wait_for_downloads": ie.wait_for_downloads
53+
},
4454
}

botcity/web/browsers/ie.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Dict
2+
3+
from selenium.webdriver import Ie # noqa: F401, F403
4+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
5+
from selenium.webdriver.ie.options import Options
6+
7+
8+
def default_options(headless=False, download_folder_path=None, user_data_dir=None) -> Options:
9+
"""Retrieve the default options for this browser curated by BotCity.
10+
11+
Returns:
12+
Options: The Internet Explorer options.
13+
"""
14+
ie_options = Options()
15+
ie_options.add_argument("-embedding")
16+
ie_options.add_argument("-extoff")
17+
ie_options.add_argument("-k")
18+
return ie_options
19+
20+
21+
def default_capabilities() -> Dict:
22+
"""Fetch the default capabilities for this browser.
23+
24+
Returns:
25+
Dict: Dictionary with the default capabilities defined.
26+
"""
27+
return DesiredCapabilities.INTERNETEXPLORER.copy()
28+
29+
30+
def wait_for_downloads(driver):
31+
"""Wait for all downloads to finish.
32+
"""
33+
raise NotImplementedError('wait_for_downloads not yet supported')

docs/browsers.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ from botcity.web.browsers.chrome import default_options, default_capabilities
1515
#from botcity.web.browsers.firefox import default_options, default_capabilities
1616
# For Edge
1717
#from botcity.web.browsers.edge import default_options, default_capabilities
18+
# For IE
19+
#from botcity.web.browsers.ie import default_options, default_capabilities
1820

1921

2022
class Bot(WebBot):
@@ -77,3 +79,19 @@ Here are the documentation for the methods mentioned above for each of the suppo
7779
::: botcity.web.browsers.edge.default_capabilities
7880
rendering:
7981
heading_level: 4
82+
83+
### IE
84+
::: botcity.web.browsers.ie.default_options
85+
rendering:
86+
heading_level: 4
87+
::: botcity.web.browsers.ie.default_capabilities
88+
rendering:
89+
heading_level: 4
90+
91+
#### Important
92+
93+
If you have any questions about the driver see [IE Driver Server Documentation](https://www.selenium.dev/documentation/ie_driver_server/).
94+
95+
See the [list of supported arguments in IE](https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/hh826025(v=vs.85)).
96+
97+
During execution some errors may occur, [see the list of common errors](https://testguild.com/selenium-webdriver-fix-for-3-common-ie-errors/).

0 commit comments

Comments
 (0)