Using python selenium for Microsoft edge

2024/12/9 22:23:49

I am trying to use pythons selenium for Microsoft edge but I keep getting this error:

WebDriverException: Message: unknown error: cannot find Microsoft Edge binary

I downloaded the latest version of the edge driver. Here is my code:

from selenium import webdriver
from selenium.webdriver.remote import webelement
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
import time
from bs4 import BeautifulSoup
import os
from datetime import datetime
from selenium.webdriver import ActionChainsdriver = webdriver.Edge(executable_path = 'C:\\Users\\Downloads\\edgedriver_win32\\msedgedriver.exe')
def get_trulia_estimate(address):driver.get('https://www.trulia.com/')print(address)element = (By.ID, 'homepageSearchBoxTextInput')WebDriverWait(driver, 10).until(EC.element_to_be_clickable(element)).click()WebDriverWait(driver, 10).until(EC.element_to_be_clickable(element)).send_keys(address)search_button = (By.CSS_SELECTOR, "button[data-auto-test-id='searchButton']")WebDriverWait(driver, 50).until(EC.element_to_be_clickable(search_button)).click()time.sleep(3) 
Answer

This post is quite old now, but hopefully I can help anyone that stumbles upon the same issue in future!

The problem is that you're using the wrong webdriver. Edge exists in two different versions, implemented on two non-interchangeable engines -- Chromium Edge and EdgeHTML (the default version at the time of writing). Each of these two versions has a different webdriver associated with it, with Chromium Edge's being "msedgedriver.exe", and EdgeHTML's being "MicrosoftWebDriver.exe".

You are using the EdgeHTML version of Edge, while trying to run the Chromium Edge webdriver. The 'cannot find Microsoft Edge binary' error Selenium spits out comes from this.

Luckily it is easy to install the right webdriver. If you have a Edge 17 or older, you can install the driver here. Make sure you download the EdgeHTML driver, not the Chromium driver, and add it to your PATH. For Edge 18 and later, you don't have to download anything. Simply run in the command prompt the command: DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0.

https://en.xdnf.cn/q/72695.html

Related Q&A

get all unicode variations of a latin character

E.g., for the character "a", I want to get a string (list of chars) like "aāăą" (not sure if that example list is complete...) (basically all unicode chars with names "Latin…

How do I install Django on Ubuntu 11.10?

Im using The Definitive guide to installing Django on ubuntu and ironically need something more definitive because I cant make it work.(I have followed the steps before this on the link above) Here is …

Sympy second order ode

I have a homogeneous solution to a simple second-order ODE, which when I try to solve for initial values using Sympy, returns the same solution. It should substitute for y(0) and y(0) and yield a solut…

Bulk update using Peewee library

Im trying to update many records inside a table using Peewee library. Inside a for loop, i fetch a single record and then I update it but this sounds awful in terms of performance so I need to do the u…

Can you specify variance in a Python type annotation?

Can you spot the error in the code below? Mypy cant.from typing import Dict, Anydef add_items(d: Dict[str, Any]) -> None:d[foo] = 5d: Dict[str, str] = {} add_items(d)for key, value in d.items():pr…

Django loaddata error

I created a "fixtures" folder in the app directory and put data1.json in there.This is what is in the file:[{"firm_url": "http://www.graychase.com/kadam", "firm_name&…

Parsing JSON string/object in Python

Ive recently started working with JSON in python. Now Im passing a JSON string to Python(Django) through a post request. Now I want to parse/iterate of that data. But I cant find a elegant way to parse…

Removing NaNs in numpy arrays

I have two numpy arrays that contains NaNs:A = np.array([np.nan, 2, np.nan, 3, 4]) B = np.array([ 1 , 2, 3 , 4, np.nan])are there any smart way using numpy to remove the NaNs in b…

Run Python + OpenCV + dlib in Azure Functions

I have created an image processing script in Python (with dlib and OpenCV) - I was wondering how I can bring this functionality to Azure Functions, so that the script can be called via an API. As Pytho…

Best way to add python scripting into QT application?

I have a QT 4.6 application (C++ language) and i need to add python scripting to it on windows platform. Unfortunately, i never embed python before, and it seems to be a lot of different ways to do so.…