Skip to content

Commit 56b4907

Browse files
committed
ENH: IE support
1 parent e363131 commit 56b4907

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
Useful links:
12+
IE Driver Documentation: https://www.selenium.dev/documentation/ie_driver_server/
13+
IE Command-Line Options: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/hh826025(v=vs.85)
14+
15+
Returns:
16+
Options: The Internet Explorer options.
17+
"""
18+
ie_options = Options()
19+
ie_options.add_argument("-embedding")
20+
ie_options.add_argument("-extoff")
21+
ie_options.add_argument("-k")
22+
return ie_options
23+
24+
25+
def default_capabilities() -> Dict:
26+
"""Fetch the default capabilities for this browser.
27+
28+
Returns:
29+
Dict: Dictionary with the default capabilities defined.
30+
"""
31+
return DesiredCapabilities.INTERNETEXPLORER.copy()
32+
33+
34+
def wait_for_downloads(driver):
35+
"""Wait for all downloads to finish.
36+
"""
37+
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)