简体   繁体   中英

Is there a COM interface for Edge Chromium similar to that provided by Internet Explorer?

Internet Explorer provides a COM interface that allows full control of an IE instance and navigating the DOM of a loaded web page. Does Edge Chromium provide something similar?

I currently use PowerShell scripts to open IE, browse to a number of pages and navigate the DOM on each page to extract data from elements on each page, so wanted to do the same using Ede Chromium.

You cannot automate the Edge Chromium browser like you are automating the IE browser using PowerShell script.

To automate the Edge Chromium browser, I suggest trying to use the Microsoft web driver .

Selenium web driver supports many developing languages, you can choose the desired language.

Here are steps to automate the Edge Chromium browser using a web driver in C# language.

  1. Download the correct Microsoft WebDriver version for your build of Microsoft Edge.

  2. Create a C# Console application in the Visual Studio.

  3. Install the Selenium.webDriver and Microsoft.Edge.SeleniumTools packages via Nuget package manager.

  4. Add the code below and modify the paths in the code.

Code:

static void Main(string[] args)
{
            var options = new EdgeOptions();
            options.UseChromium = true;
            options.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
           
            var driver = new Microsoft.Edge.SeleniumTools.EdgeDriver(@"--<Edge web driver path>--", options);
            driver.Navigate().GoToUrl("--<URL of the site>--");
}

Further, you can modify the code example as per your own requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM