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