Skip to content

Microsoft Edge

MSEdgeBrowser

A class that provides an interface for interacting with the Microsoft Edge browser using Selenium WebDriver. It adheres to the BrowserInterface to ensure compatibility with the Speed Sleuth's browser handling.

Attributes:

Name Type Description
binary_path str

The file path to the Microsoft Edge browser executable.

headless bool

Run in headless mode, i.e., without a UI or display server dependencies

Methods:

Name Description
load_driver

Creates and returns a configured Selenium WebDriver instance for the Chromium browser.

Source code in src/speed_sleuth/browser/ms_edge.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@BrowserInterface.register
class MSEdgeBrowser:
    """A class that provides an interface for interacting with the Microsoft
    Edge browser using Selenium WebDriver. It adheres to the BrowserInterface
    to ensure compatibility with the Speed Sleuth's browser handling.

    Attributes:
        binary_path (str): The file path to the Microsoft Edge browser
            executable.
        headless (bool, optional): Run in headless mode, i.e., without a UI
                or display server dependencies

    Methods:
        load_driver(): Creates and returns a configured Selenium WebDriver
            instance for the Chromium browser.

    """

    def __init__(self, binary_path=None, headless=False):
        self.binary_path = binary_path
        self.headless = headless

    def load_driver(self) -> WebDriver:
        """Initializes and returns a Selenium WebDriver for Microsoft Edge with
        specified options.

        The method sets up the driver with a custom binary location for
        the Edge browser, window size, and language. It disables GPU
        acceleration to ensure compatibility across different systems.
        The driver is configured to wait until the page's readyState is
        'complete' before returning, ensuring that the page is fully
        loaded.

        Returns:
            WebDriver: An instance of Selenium WebDriver configured for
                Microsoft Edge.

        """

        edge_service = service.Service()
        edge_options = options.Options()

        if self.binary_path:
            edge_options.binary_location = self.binary_path
        if self.headless:
            edge_options.add_argument("--headless")
        edge_options.add_argument("--window-size=1400x900")
        edge_options.add_argument("--disable-gpu")
        edge_options.add_argument("--lang=en_US")
        return webdriver.Edge(service=edge_service, options=edge_options)

load_driver()

Initializes and returns a Selenium WebDriver for Microsoft Edge with specified options.

The method sets up the driver with a custom binary location for the Edge browser, window size, and language. It disables GPU acceleration to ensure compatibility across different systems. The driver is configured to wait until the page's readyState is 'complete' before returning, ensuring that the page is fully loaded.

Returns:

Name Type Description
WebDriver WebDriver

An instance of Selenium WebDriver configured for Microsoft Edge.

Source code in src/speed_sleuth/browser/ms_edge.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def load_driver(self) -> WebDriver:
    """Initializes and returns a Selenium WebDriver for Microsoft Edge with
    specified options.

    The method sets up the driver with a custom binary location for
    the Edge browser, window size, and language. It disables GPU
    acceleration to ensure compatibility across different systems.
    The driver is configured to wait until the page's readyState is
    'complete' before returning, ensuring that the page is fully
    loaded.

    Returns:
        WebDriver: An instance of Selenium WebDriver configured for
            Microsoft Edge.

    """

    edge_service = service.Service()
    edge_options = options.Options()

    if self.binary_path:
        edge_options.binary_location = self.binary_path
    if self.headless:
        edge_options.add_argument("--headless")
    edge_options.add_argument("--window-size=1400x900")
    edge_options.add_argument("--disable-gpu")
    edge_options.add_argument("--lang=en_US")
    return webdriver.Edge(service=edge_service, options=edge_options)