是否可以从单独的进程读取/写入MS Edge中加载的网页 [英] Is it possible to read / write a web page loaded in MS Edge from a separate process

查看:60
本文介绍了是否可以从单独的进程读取/写入MS Edge中加载的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这个问题并不完全符合SO的标准,但我希望有人能告诉我我在浪费时间或将我指向正确的方向.

I realize this question isn't exactly up to SO's standards but I'm hoping someone can tell me I'm wasting my time or point me in the correct direction.

我想知道是否存在用于处理Edge中加载的网页的低级API.我正在从事一个自动化项目,该项目需要能够实时解析DOM,注入元素,从单独的过程中获取/设置输入值.

I'm wondering if there was a low level API for manipulating a web page loaded in Edge. I'm working on an automation project that needs to be able to parse the DOM, inject elements, get / set input values from a separate process in real time.

我无法在网上找到任何可能的方法,但我担心我什至找不到合适的位置.

I have not been able to find ANYTHING online that suggests this is possible but I'm worried I might not even be looking in the right places.

谢谢!

推荐答案

Shawn,看看Selenium WebDriver for Microsoft Edge.它通常用作质量检查工具,但我认为没有理由您无法以这种方式进行这些操作.

Shawn, take a look at the Selenium WebDriver for Microsoft Edge. It's normally used as a QA tool, but I see no reason why you couldn't do those things this way.

根据WebDriver的W3C定义

From the W3C definition of the WebDriver

WebDriver是一个远程控制界面,可以对用户代理进行自省和控制.它提供了平台和语言无关的有线协议,作为进程外程序远程指示Web浏览器行为的一种方式. 提供了一组接口,用于发现和操作Web文档中的DOM元素并控制用户代理的行为.它的主要目的是允许网络作者编写测试,以使用户代理程序从单独的控制过程中自动执行,但也可以以允许浏览器内的脚本控制(可能是单独的)浏览器的方式使用.

WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers. Provided is a set of interfaces to discover and manipulate DOM elements in web documents and to control the behavior of a user agent. It is primarily intended to allow web authors to write tests that automate a user agent from a separate controlling process, but may also be used in such a way as to allow in-browser scripts to control a — possibly separate — browser

我相信这代表了您想要做的大部分事情.以下是一些有用的链接,可帮助您入门.

I believe that represents most of what you want to do. Here are some useful links that will help you get started.

  • Download link for WebDriver For Edge
  • W3C Spec
  • Selenium Components
  • Dev Guide

这是从MSFT Gist中摘录的一些示例C#代码

Here is some sample C# code nabbed from a MSFT Gist

using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System;

namespace EdgeDriverTests
{
    public class Program
    {
        /*
        * This assumes you have added MicrosoftWebDriver.exe to your System Path.
        * For help on adding an exe to your System Path, please see:
        * https://msdn.microsoft.com/en-us/library/office/ee537574(v=office.14).aspx
        */
        static void Main(string[] args)
        {
            /* You can find the latest version of Microsoft WebDriver here:
            * https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
            */
            var driver = new EdgeDriver();

            // Navigate to Bing
            driver.Url = "https://www.bing.com/";

            // Find the search box and query for webdriver
            var element = driver.FindElementById("sb_form_q");

            element.SendKeys("webdriver");
            element.SendKeys(Keys.Enter);

            Console.ReadLine();
            driver.Quit();
        }
    }
}

这篇关于是否可以从单独的进程读取/写入MS Edge中加载的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆