Selenium: Automate Internet explorer apps using Edge

Photo by Alan Tang on Unsplash

Selenium: Automate Internet explorer apps using Edge

Introduction

Automating Internet explorer is hard nowadays because internet explorer has been retired by Microsoft on June 15, 2022. Most of the organization are still dependent on legacy application which are only supported by internet explorer. Here i will show you how you can automate edge in IE mode to automate legacy applications using python and selenium.

What is IE Mode?

Microsoft provides a special feature in Edge browser called IE mode. Using IE mode you can switch between internet explorer mode and Edge mode. This mode feels exactly same as internet explorer.

Challenges

  • You cannot use EgdeDriver to automate the Edge browser in IE mode.
  • You cannot inspect code in IE mode
  • Sometimes code gets stuck or selenium doesn't work

So without any further due let's get into the solution.

Requirements

  • Python version 3.7 and above
  • Selenium package version 4.4.0 or above
  • Internet explorer driver i.e. IEDriverServer version 4.3.0.0 or above — download from here.

IE Debugger

Edge does not allow to launch devtools in IE mode. So use the below steps to launch IEChooser. To debug the content of an IE mode tab, use to open Internet Explorer DevTools, as follows:

  • In Windows, open the Run dialog box. For example, press the Windows logo key + R.
  • Enter %systemroot%\system32\f12\IEChooser.exe, and then click OK.
  • In IEChooser, select the entry for the IE mode tab.

Folder Structure

Folder
    L  app.py
    L IEDriverServer.exe

Install Package

pip install selenium==4.4.0

Code Snippets

from selenium import webdriver

class App:
    def __init__(self) -> None:
        ie_options = webdriver.IeOptions()
        ie_options.attach_to_edge_chrome = True
        ie_options.ignore_zoom_level = True
        # Add the path of microsoft edge executable in the below line of code
        ie_options.edge_executable_path = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
        driver_path = "IEDriverServer.exe" 
        Service(executable=driver_path)
        self.driver = webdriver.Ie(options=ie_options)

    def test(self):
        driver.get("https://www.google.com")
        driver.find_element_by_id("input").send_keys("Medium")
        print("Success")

    def quit(self):
        self.driver.quit()


app = App()
app.test()
app.quit()

This is how we have to configure python selenium script so that we can automate Edge in IE mode. Hope this blog will help you in your automation journey.

If you have any query/suggetions/feedback please connect with me on twitter

Meet you on the next blog.

Did you find this article valuable?

Support Ashish Jaiswar by becoming a sponsor. Any amount is appreciated!