Исходный код вики GeckoFX
Версия 5.3 от Alexandr Fokin на 2021/08/12 12:01
Последние авторы
author | version | line-number | content |
---|---|---|---|
1 | GeckoFX 1.0.5 | ||
2 | https://www.nuget.org/packages/GeckoFX/1.0.5 | ||
3 | |||
4 | {{code language="c#"}} | ||
5 | |||
6 | // Change html attribute | ||
7 | var usernameInput = geckoWebBrowser1.Document.GetElementById("j_username"); | ||
8 | usernameInput.SetAttribute("value", "abc"); | ||
9 | |||
10 | |||
11 | // ButtonClick | ||
12 | var buttonElement = geckoWebBrowser1.Document.GetElementById("button"); | ||
13 | new GeckoButtonElement(buttonElement.DOMElement).Click(); | ||
14 | |||
15 | |||
16 | // FormSubmit | ||
17 | var form = geckoWebBrowser1.Document.GetElementById("loginForm"); | ||
18 | (form as GeckoFormElement).submit(); | ||
19 | |||
20 | |||
21 | // Execute JS | ||
22 | using (AutoJSContext context = new AutoJSContext(geckoWebBrowser1.Window)) | ||
23 | { | ||
24 | var result1 = context.EvaluateScript( | ||
25 | "(() => { return 2; })()", | ||
26 | (nsISupports)geckoWebBrowser1.Window.DomWindow, | ||
27 | out res | ||
28 | ); | ||
29 | |||
30 | var result2 = context.EvaluateScript( | ||
31 | "document.getElementById('loginForm').submit()", | ||
32 | (nsISupports)geckoWebBrowser1.Window.DomWindow, | ||
33 | out res | ||
34 | ); | ||
35 | } | ||
36 | |||
37 | {{/code}} |