Use IE Driver to automate IE mode in Microsoft Edge

Mia Wu-MSFT 327 Reputation points Microsoft Employee Moderator
2022-07-28T03:00:51.14+00:00

From the official document, I tried below Python scripts to launch Microsoft Edge in IE mode.

from selenium import webdriver  
from selenium.webdriver.common.by import By  
from selenium.webdriver.common.keys import Keys  
  
ie_options = webdriver.IeOptions()  
ie_options.attach_to_edge_chrome = True  
ie_options.edge_executable_path = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"  
  
driver = webdriver.Ie(options=ie_options)  
  
driver.get("http://www.bing.com")  
elem = driver.find_element(By.ID, 'sb_form_q')  
elem.send_keys('WebDriver' + Keys.RETURN)  
  
driver.quit()  

The expected result is the browser will navigate to bing.com, and then search for "WebDriver". However, the actual shown page is like this:
225504-image.png

Is this the expected behavior or there is something wrong with the codes?

Microsoft Edge Microsoft Edge development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mia Wu-MSFT 327 Reputation points Microsoft Employee Moderator
    2022-07-28T04:15:49.44+00:00

    I solved it by adding ie_options.ignore_zoom_level = True. The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates. Refer to [here] (https://www.selenium.dev/documentation/ie_driver_server/#required-configuration).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.