Automated Browser Testing with Edge and Selenium in Python (original) (raw)

Last Updated : 23 Jul, 2025

Cross-browser testing is mandatory in the software industry. We all know that there are many browsers like Firefox, Chrome, Edge, Opera etc., are available. Rather than writing separate code to each and every browser, it is always a decent approach to go towards automated testing. Let us see how to do that using Selenium for Edge browser in Python. Here Edge WebDriver is used in order to run our Selenium automation test scripts over the Edge browser.

Requirements

In order to perform Browser Automation using Edge And Selenium In Python, we need to carry out the following steps:

pip install selenium

pip install msedge-selenium-tools selenium==3.141

Below is a program to execute a simple automated browser testing script:

Python `

import required modules

from selenium import webdriver

Driver Code

if name == 'main':

# create object
edgeBrowser = webdriver.Edge(r"msedgedriver.exe")

# open browser and navigate to lambdatest Login Page
edgeBrowser.get('https://www.lambdatest.com')

`

Output:

lambda login page

LambdaTest Login Page Opened by Edge

On executing the script, we can see, edge browser has opened Facebook page as shown in the image. You can open any valid web page and automatically it will open the mentioned web page in edge browser.

Step for Automation of Browser Testing with Edge and Selenium

**1. Platform Selection

Choose the appropriate testing platforms. You can choose a local grid or a cloud grid like LambdaTest for scalability and reliability. It is an AI-powered test orchestration and execution platform that allows you to perform automated browser testing with Selenium, Python across different Edge browser versions. With LambdaTest, you can:

2. Browser Compatibility

3. Automated Actions:

4. Data Parameterization

5. Dynamic Element Identification

6. Submit Action and Verification

7. Advanced Features

Implementation

Python `

Import required module

from selenium.webdriver.opera.options import Options from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException from selenium import webdriver from time import sleep

Driver Code

if name == 'main':

# Instantiate the webdriver with the executable location of MS Edge
# Provide the full location of the path to recognise correctly
edgeBrowser = webdriver.Edge(r"msedgedriver.exe")

# This is the step for maximizing browser window
edgeBrowser.maximize_window()

# Browser will get navigated to the given URL
edgeBrowser.get('https://www.lambdatest.com')
try:
    # We need to insert Email in order to proceed further. 
    # So it is given by using 'useremail'
    sampleElement = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.ID, 'useremail')))
    
    # We can give a valid email address and since 
    # this page carries the email id alone, it just 
    # appends the email id at the end
    sampleElement.send_keys("gfg@lambdatest.com")
    
    # A click is happening to move to next page
    sampleElement.click()
    
    # A Submit button is searched to click and start 
    # free testing. Actually "testing_form" is the id 
    # of the form, which needs to get tested
    sampleElement2 = WebDriverWait(browser, 10).until(
        EC.element_to_be_clickable((By.CSS_SELECTOR, 
                                    "#testing_form > div")))
    
    # Starting free testing on LambdaTest
    sampleElement2.click()
    
    # Just to show the set of actions happening, we can 
    # give sleep, you can change the values as per requirement
    sleep(20)
except TimeoutException:
    print("Trying to find the given element but unfortunately no element is found")
sleep(20)
# Once all operations over, we can close browser too
# edgeBrowser.close()

`

Output

Automated browser testing is very convenient and as separate drivers are available for each browser, we can do the testing easily and no manual work is needed. Even automated testing is faster and can test multiple test pages very quickly and provide successful test results.