3

在 AngleSharpIHtmlAnchorElement中有 DoClick()方法。就我而言,我需要单击div. 我该怎么做?

HTML:

<div role="button" class="div"></div>

C#:

IHtmlAnchorElement anc = document.Anchors.First(x => x.ClassName == "anc");
anc.DoClick();
IElement div = document.All.First(x => x.ClassName == "div");
//! DoClick on div?
4

1 回答 1

2

A quick Look into the code i foundout that the IHtmlElement interfaces is the one that holds the DoClick(); Method.

That Interface documentation says:

The HTMLElement interface represents any HTML element. Some elements directly implement this interface, other implement it via an interface that inherit it.

So it actually is fitting for your needs, rather than the more Abstract interface IElement which IHtmlElement inherits from.

This should make it appear.

IHtmlElement div = document.All.First(x => x.ClassName == "div");
div.DoClick();
于 2018-05-03T08:50:38.287 回答