This repository was archived by the owner on Jan 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFsExample.fs
More file actions
89 lines (65 loc) · 2.91 KB
/
Copy pathFsExample.fs
File metadata and controls
89 lines (65 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
namespace Example
open System
open System.Threading
open ZennoLab.CommandCenter
open ZennoLab.Emulation
open ZennoLab.InterfacesLibrary.ProjectModel
open ZennoLab.InterfacesLibrary.ProjectModel.Enums
open Example.Extensions
type Lang = En | Ru
type TemplateExample(instance: Instance, project: IZennoPosterProjectModel) =
member this.Run() =
let tab = instance.ActiveTab
let toLog = project.SendInfoToLog
let langState =
match project.Profile.Language with
| lang when lang.CompareStr("en") -> Lang.En
| lang when lang.CompareStr("ru") -> Lang.Ru
| _ -> failwith ("Неподдерживаемый язык")
let getLangWord (ru, en) =
match langState with
| Lang.Ru -> ru
| Lang.En -> en
toLog "Установка белого списка url"
instance.SetContentPolicy(policy = "WhiteList", regexs = [| "lessons.zennolab.com" |])
toLog "Открытие страницы в соответствии с профилем"
tab.OpenPage ("https://lessons.zennolab.com/" + getLangWord("ru", "en") + "/index")
let list = [|
"Windows";
"*nix";
"Mac OS";
getLangWord ("Другая", "Other");
getLangWord ("Россия", "USA");
|]
toLog "Выбор элементов"
for text in list do
toLog ("Выбор " + text)
tab.FoundAndClick ("id('inputs')//h2[contains(text(), '" + text + "')]/preceding-sibling::input[1]")
toLog "Ввод текста"
tab.FoundAndClick "//textarea[@name='text']"
instance.SendText (project.Profile.Name + " " +
project.Profile.Surname + " " +
getLangWord ("возраст:", "age:") + " " +
project.Profile.Age.ToString(), 50)
toLog "Выбор пола"
if project.Profile.Sex = ProfileSex.Male then
tab.FoundAndClick "//select[@name='gender']"
Emulator.SendKey(tab.Handle, Windows.Forms.Keys.Up, KeyboardEvent.Press) |> ignore
toLog "Выбор языка"
tab.FoundAndClick ("//option[text()='" + getLangWord ("Русский", "English") + "']")
toLog "Выбор возраста"
let age = project.Profile.Age
let option =
if age < 16 then 1
elif 16 <= age && age <= 30 then 2
elif 31 <= age && age <= 60 then 3
else 4
tab.FoundAndClick ("//option[text()='" + getLangWord ("Возраст:", "Age:") + "']/following-sibling::option[" + (string) option + "]")
0
type public Main() =
interface IZennoCustomCode with
member this.ExecuteCode(instance: Instance, project: IZennoPosterProjectModel): int =
TemplateExample(instance, project).Run()
interface IZennoCustomEndCode with
member this.GoodEnd(instance, project) = ()
member this.BadEnd(instance, project) = ()