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