hotstaq 0.5.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +17 -0
- package/.eslintrc.js +11 -0
- package/.vscode/launch.json +199 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +78 -0
- package/CONTRIBUTING.md +157 -0
- package/README.md +126 -0
- package/bin/hotstaq +3 -0
- package/bin/hotstaq.cmd +1 -0
- package/build/src/Hot.d.ts +167 -0
- package/build/src/Hot.d.ts.map +1 -0
- package/build/src/Hot.js +365 -0
- package/build/src/Hot.js.map +1 -0
- package/build/src/HotAPI.d.ts +130 -0
- package/build/src/HotAPI.d.ts.map +1 -0
- package/build/src/HotAPI.js +353 -0
- package/build/src/HotAPI.js.map +1 -0
- package/build/src/HotAgentAPI.d.ts +22 -0
- package/build/src/HotAgentAPI.d.ts.map +1 -0
- package/build/src/HotAgentAPI.js +85 -0
- package/build/src/HotAgentAPI.js.map +1 -0
- package/build/src/HotAgentRoute.d.ts +17 -0
- package/build/src/HotAgentRoute.d.ts.map +1 -0
- package/build/src/HotAgentRoute.js +109 -0
- package/build/src/HotAgentRoute.js.map +1 -0
- package/build/src/HotBuilder.d.ts +52 -0
- package/build/src/HotBuilder.d.ts.map +1 -0
- package/build/src/HotBuilder.js +239 -0
- package/build/src/HotBuilder.js.map +1 -0
- package/build/src/HotClient.d.ts +31 -0
- package/build/src/HotClient.d.ts.map +1 -0
- package/build/src/HotClient.js +19 -0
- package/build/src/HotClient.js.map +1 -0
- package/build/src/HotComponent.d.ts +118 -0
- package/build/src/HotComponent.d.ts.map +1 -0
- package/build/src/HotComponent.js +89 -0
- package/build/src/HotComponent.js.map +1 -0
- package/build/src/HotCreator.d.ts +92 -0
- package/build/src/HotCreator.d.ts.map +1 -0
- package/build/src/HotCreator.js +465 -0
- package/build/src/HotCreator.js.map +1 -0
- package/build/src/HotDB.d.ts +69 -0
- package/build/src/HotDB.d.ts.map +1 -0
- package/build/src/HotDB.js +29 -0
- package/build/src/HotDB.js.map +1 -0
- package/build/src/HotDBConnectionInterface.d.ts +40 -0
- package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
- package/build/src/HotDBConnectionInterface.js +3 -0
- package/build/src/HotDBConnectionInterface.js.map +1 -0
- package/build/src/HotFile.d.ts +134 -0
- package/build/src/HotFile.d.ts.map +1 -0
- package/build/src/HotFile.js +454 -0
- package/build/src/HotFile.js.map +1 -0
- package/build/src/HotHTTPServer.d.ts +162 -0
- package/build/src/HotHTTPServer.d.ts.map +1 -0
- package/build/src/HotHTTPServer.js +863 -0
- package/build/src/HotHTTPServer.js.map +1 -0
- package/build/src/HotIO.d.ts +39 -0
- package/build/src/HotIO.d.ts.map +1 -0
- package/build/src/HotIO.js +195 -0
- package/build/src/HotIO.js.map +1 -0
- package/build/src/HotLog.d.ts +60 -0
- package/build/src/HotLog.d.ts.map +1 -0
- package/build/src/HotLog.js +126 -0
- package/build/src/HotLog.js.map +1 -0
- package/build/src/HotPage.d.ts +125 -0
- package/build/src/HotPage.d.ts.map +1 -0
- package/build/src/HotPage.js +178 -0
- package/build/src/HotPage.js.map +1 -0
- package/build/src/HotRoute.d.ts +82 -0
- package/build/src/HotRoute.d.ts.map +1 -0
- package/build/src/HotRoute.js +83 -0
- package/build/src/HotRoute.js.map +1 -0
- package/build/src/HotRouteMethod.d.ts +129 -0
- package/build/src/HotRouteMethod.d.ts.map +1 -0
- package/build/src/HotRouteMethod.js +84 -0
- package/build/src/HotRouteMethod.js.map +1 -0
- package/build/src/HotServer.d.ts +152 -0
- package/build/src/HotServer.d.ts.map +1 -0
- package/build/src/HotServer.js +109 -0
- package/build/src/HotServer.js.map +1 -0
- package/build/src/HotSetAsWeb.d.ts +2 -0
- package/build/src/HotSetAsWeb.d.ts.map +1 -0
- package/build/src/HotSetAsWeb.js +5 -0
- package/build/src/HotSetAsWeb.js.map +1 -0
- package/build/src/HotStaq.d.ts +601 -0
- package/build/src/HotStaq.d.ts.map +1 -0
- package/build/src/HotStaq.js +1258 -0
- package/build/src/HotStaq.js.map +1 -0
- package/build/src/HotStaqWeb.d.ts +18 -0
- package/build/src/HotStaqWeb.d.ts.map +1 -0
- package/build/src/HotStaqWeb.js +44 -0
- package/build/src/HotStaqWeb.js.map +1 -0
- package/build/src/HotTestDriver.d.ts +63 -0
- package/build/src/HotTestDriver.d.ts.map +1 -0
- package/build/src/HotTestDriver.js +187 -0
- package/build/src/HotTestDriver.js.map +1 -0
- package/build/src/HotTestElement.d.ts +71 -0
- package/build/src/HotTestElement.d.ts.map +1 -0
- package/build/src/HotTestElement.js +37 -0
- package/build/src/HotTestElement.js.map +1 -0
- package/build/src/HotTestMap.d.ts +83 -0
- package/build/src/HotTestMap.d.ts.map +1 -0
- package/build/src/HotTestMap.js +58 -0
- package/build/src/HotTestMap.js.map +1 -0
- package/build/src/HotTestSeleniumDriver.d.ts +82 -0
- package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
- package/build/src/HotTestSeleniumDriver.js +398 -0
- package/build/src/HotTestSeleniumDriver.js.map +1 -0
- package/build/src/HotTester.d.ts +188 -0
- package/build/src/HotTester.d.ts.map +1 -0
- package/build/src/HotTester.js +623 -0
- package/build/src/HotTester.js.map +1 -0
- package/build/src/HotTesterAPI.d.ts +15 -0
- package/build/src/HotTesterAPI.d.ts.map +1 -0
- package/build/src/HotTesterAPI.js +161 -0
- package/build/src/HotTesterAPI.js.map +1 -0
- package/build/src/HotTesterMocha.d.ts +50 -0
- package/build/src/HotTesterMocha.d.ts.map +1 -0
- package/build/src/HotTesterMocha.js +205 -0
- package/build/src/HotTesterMocha.js.map +1 -0
- package/build/src/HotTesterMochaSelenium.d.ts +70 -0
- package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
- package/build/src/HotTesterMochaSelenium.js +257 -0
- package/build/src/HotTesterMochaSelenium.js.map +1 -0
- package/build/src/HotTesterServer.d.ts +114 -0
- package/build/src/HotTesterServer.d.ts.map +1 -0
- package/build/src/HotTesterServer.js +575 -0
- package/build/src/HotTesterServer.js.map +1 -0
- package/build/src/api.d.ts +33 -0
- package/build/src/api.d.ts.map +1 -0
- package/build/src/api.js +78 -0
- package/build/src/api.js.map +1 -0
- package/build/src/cli.d.ts +2 -0
- package/build/src/cli.d.ts.map +1 -0
- package/build/src/cli.js +935 -0
- package/build/src/cli.js.map +1 -0
- package/build/src/schemas/HotDBInflux.d.ts +63 -0
- package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
- package/build/src/schemas/HotDBInflux.js +239 -0
- package/build/src/schemas/HotDBInflux.js.map +1 -0
- package/build/src/schemas/HotDBMigration.d.ts +19 -0
- package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
- package/build/src/schemas/HotDBMigration.js +15 -0
- package/build/src/schemas/HotDBMigration.js.map +1 -0
- package/build/src/schemas/HotDBMySQL.d.ts +65 -0
- package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
- package/build/src/schemas/HotDBMySQL.js +387 -0
- package/build/src/schemas/HotDBMySQL.js.map +1 -0
- package/build/src/schemas/HotDBSchema.d.ts +15 -0
- package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
- package/build/src/schemas/HotDBSchema.js +19 -0
- package/build/src/schemas/HotDBSchema.js.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.js +33 -0
- package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.js +151 -0
- package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
- package/build-web/HotStaq.js +2 -0
- package/build-web/HotStaq.min.js +125 -0
- package/builder/docker/Dockerfile.linux.gen +42 -0
- package/builder/docker/README.md +36 -0
- package/builder/docker/app/start.sh +8 -0
- package/builder/docker/dockerignore +3 -0
- package/builder/docker/scripts/build.bat +11 -0
- package/builder/docker/scripts/build.sh +11 -0
- package/builder/docker/scripts/start-app.bat +7 -0
- package/builder/docker/scripts/start-app.sh +7 -0
- package/builder/docker/scripts/stop-app.bat +5 -0
- package/builder/docker/scripts/stop-app.sh +5 -0
- package/builder/docker-compose/docker-compose.gen.yaml +41 -0
- package/builder/docker-compose/env-skeleton +4 -0
- package/creator/project/.vscode/launch.json +59 -0
- package/creator/project/README.md +20 -0
- package/creator/project/gitignore +118 -0
- package/creator/project/npmignore +118 -0
- package/creator/public/api-test.hott +28 -0
- package/creator/public/index.hott +12 -0
- package/creator/ts/src/AppAPI.ts +30 -0
- package/creator/ts/src/HelloWorld.ts +39 -0
- package/creator/ts/src/WebExport.ts +7 -0
- package/creator/ts/tsconfig-web.json +73 -0
- package/creator/ts/tsconfig.json +73 -0
- package/creator/ts/webpack-api.config.js +57 -0
- package/dbstart.sh +19 -0
- package/dbstop.sh +4 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +128 -0
- package/docs/classes/Hot.md +477 -0
- package/docs/classes/HotAPI.md +369 -0
- package/docs/classes/HotClient.md +95 -0
- package/docs/classes/HotComponent.md +279 -0
- package/docs/classes/HotDB.md +247 -0
- package/docs/classes/HotDBInflux.md +404 -0
- package/docs/classes/HotDBMigration.md +80 -0
- package/docs/classes/HotDBMySQL.md +310 -0
- package/docs/classes/HotDBSchema.md +51 -0
- package/docs/classes/HotFile.md +353 -0
- package/docs/classes/HotHTTPServer.md +700 -0
- package/docs/classes/HotLog.md +162 -0
- package/docs/classes/HotPage.md +357 -0
- package/docs/classes/HotRoute.md +312 -0
- package/docs/classes/HotRouteMethod.md +271 -0
- package/docs/classes/HotServer.md +311 -0
- package/docs/classes/HotStaq.md +1153 -0
- package/docs/classes/HotTestDestination.md +58 -0
- package/docs/classes/HotTestDriver.md +332 -0
- package/docs/classes/HotTestElement.md +88 -0
- package/docs/classes/HotTestElementOptions.md +71 -0
- package/docs/classes/HotTestMap.md +92 -0
- package/docs/classes/HotTestSeleniumDriver.md +529 -0
- package/docs/classes/HotTester.md +653 -0
- package/docs/classes/HotTesterAPI.md +493 -0
- package/docs/classes/HotTesterMocha.md +843 -0
- package/docs/classes/HotTesterMochaSelenium.md +896 -0
- package/docs/classes/HotTesterServer.md +633 -0
- package/docs/classes/InfluxSchema.md +74 -0
- package/docs/classes/MySQLSchema.md +199 -0
- package/docs/classes/MySQLSchemaField.md +330 -0
- package/docs/classes/MySQLSchemaTable.md +176 -0
- package/docs/enums/ConnectionStatus.md +43 -0
- package/docs/enums/DeveloperMode.md +38 -0
- package/docs/enums/EventExecutionType.md +43 -0
- package/docs/enums/HTTPMethod.md +32 -0
- package/docs/enums/HotDBGenerationType.md +30 -0
- package/docs/enums/HotLogLevel.md +88 -0
- package/docs/interfaces/HotDBConnectionInterface.md +116 -0
- package/docs/interfaces/HotDestination.md +62 -0
- package/docs/interfaces/HotSite.md +187 -0
- package/docs/interfaces/HotSiteMapPath.md +37 -0
- package/docs/interfaces/HotSiteRoute.md +79 -0
- package/docs/interfaces/HotStartOptions.md +115 -0
- package/docs/interfaces/HotTestPage.md +44 -0
- package/docs/interfaces/HotTestStop.md +62 -0
- package/docs/interfaces/IHotComponent.md +135 -0
- package/docs/interfaces/IHotStaq.md +118 -0
- package/docs/interfaces/IHotTestElement.md +54 -0
- package/docs/interfaces/IHotTestElementOptions.md +43 -0
- package/docs/interfaces/MySQLResults.md +43 -0
- package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
- package/docs/modules.md +162 -0
- package/package.json +65 -0
- package/selenium-start.sh +7 -0
- package/selenium-stop.sh +3 -0
- package/src/Hot.ts +319 -0
- package/src/HotAPI.ts +378 -0
- package/src/HotAgentAPI.ts +43 -0
- package/src/HotAgentRoute.ts +44 -0
- package/src/HotBuilder.ts +221 -0
- package/src/HotClient.ts +40 -0
- package/src/HotComponent.ts +158 -0
- package/src/HotCreator.ts +482 -0
- package/src/HotDB.ts +79 -0
- package/src/HotDBConnectionInterface.ts +40 -0
- package/src/HotFile.ts +617 -0
- package/src/HotHTTPServer.ts +954 -0
- package/src/HotIO.ts +128 -0
- package/src/HotLog.ts +158 -0
- package/src/HotPage.ts +206 -0
- package/src/HotRoute.ts +137 -0
- package/src/HotRouteMethod.ts +216 -0
- package/src/HotServer.ts +211 -0
- package/src/HotSetAsWeb.ts +3 -0
- package/src/HotStaq.ts +1877 -0
- package/src/HotStaqWeb.ts +59 -0
- package/src/HotTestDriver.ts +172 -0
- package/src/HotTestElement.ts +97 -0
- package/src/HotTestMap.ts +130 -0
- package/src/HotTestSeleniumDriver.ts +374 -0
- package/src/HotTester.ts +697 -0
- package/src/HotTesterAPI.ts +126 -0
- package/src/HotTesterMocha.ts +133 -0
- package/src/HotTesterMochaSelenium.ts +189 -0
- package/src/HotTesterServer.ts +551 -0
- package/src/api.ts +102 -0
- package/src/cli.ts +1147 -0
- package/src/schemas/HotDBInflux.ts +211 -0
- package/src/schemas/HotDBMigration.ts +24 -0
- package/src/schemas/HotDBMySQL.ts +312 -0
- package/src/schemas/HotDBSchema.ts +21 -0
- package/src/schemas/influx/InfluxSchema.ts +19 -0
- package/src/schemas/mysql/MySQLSchema.ts +90 -0
- package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
- package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
- package/tsconfig-web.json +74 -0
- package/tsconfig.json +73 -0
- package/webpack.config.js +51 -0
- package/webpack.config.tests.js +56 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import * as oss from "os";
|
|
2
|
+
|
|
3
|
+
import { HotTestElement, HotTestElementOptions } from "./HotTestElement";
|
|
4
|
+
import { HotTestDriver } from "./HotTestDriver";
|
|
5
|
+
import { HotTestPage } from "./HotTestMap";
|
|
6
|
+
|
|
7
|
+
import { By, until, WebDriver, WebElement, Session, Builder } from "selenium-webdriver";
|
|
8
|
+
import chrome from "selenium-webdriver/chrome";
|
|
9
|
+
import firefox from "selenium-webdriver/firefox";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Runs and executes tests using Selenium.
|
|
13
|
+
*/
|
|
14
|
+
export class HotTestSeleniumDriver extends HotTestDriver
|
|
15
|
+
{
|
|
16
|
+
/**
|
|
17
|
+
* The current selenium session running.
|
|
18
|
+
*/
|
|
19
|
+
session: Session;
|
|
20
|
+
/**
|
|
21
|
+
* The selenium webdriver.
|
|
22
|
+
*/
|
|
23
|
+
driver: WebDriver;
|
|
24
|
+
/**
|
|
25
|
+
* The browser to use.
|
|
26
|
+
*/
|
|
27
|
+
browser: string;
|
|
28
|
+
/**
|
|
29
|
+
* Run the tests headless.
|
|
30
|
+
*/
|
|
31
|
+
headless: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Automatically open the developer tools on start.
|
|
34
|
+
*/
|
|
35
|
+
openDevTools: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Set the remote server to use for testing.
|
|
38
|
+
*/
|
|
39
|
+
remoteServer: string;
|
|
40
|
+
/**
|
|
41
|
+
* Set the window size on start.
|
|
42
|
+
*/
|
|
43
|
+
windowSize: {
|
|
44
|
+
/**
|
|
45
|
+
* The width of the window.
|
|
46
|
+
*/
|
|
47
|
+
width: number;
|
|
48
|
+
/**
|
|
49
|
+
* The height of the window.
|
|
50
|
+
*/
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
constructor (page: HotTestPage = null)
|
|
55
|
+
{
|
|
56
|
+
super (page);
|
|
57
|
+
|
|
58
|
+
this.driver = null;
|
|
59
|
+
this.session = null;
|
|
60
|
+
this.browser = "chrome";
|
|
61
|
+
this.headless = false;
|
|
62
|
+
this.openDevTools = false;
|
|
63
|
+
this.remoteServer = "";
|
|
64
|
+
this.windowSize = null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Disconnect this server or destroy anything associated with this HotTestDriver.
|
|
69
|
+
*/
|
|
70
|
+
async destroy (): Promise<void>
|
|
71
|
+
{
|
|
72
|
+
if (this.driver != null)
|
|
73
|
+
{
|
|
74
|
+
await this.driver.quit ();
|
|
75
|
+
|
|
76
|
+
this.driver = null;
|
|
77
|
+
this.session = null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Load the selenium driver.
|
|
83
|
+
*/
|
|
84
|
+
async loadSeleniumDriver (): Promise<void>
|
|
85
|
+
{
|
|
86
|
+
let createWindowSize = () =>
|
|
87
|
+
{
|
|
88
|
+
if (this.windowSize == null)
|
|
89
|
+
this.windowSize = { width: 1920, height: 1080 };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
let builder: Builder = new Builder ();
|
|
93
|
+
builder = builder.forBrowser (this.browser);
|
|
94
|
+
|
|
95
|
+
if (process.env["SELENIUM_REMOTE_SERVER"] != null)
|
|
96
|
+
this.remoteServer = process.env["SELENIUM_REMOTE_SERVER"];
|
|
97
|
+
|
|
98
|
+
if (process.env["SELENIUM_WINDOW_WIDTH"] != null)
|
|
99
|
+
{
|
|
100
|
+
createWindowSize ();
|
|
101
|
+
this.windowSize.width = parseFloat (process.env["SELENIUM_WINDOW_WIDTH"]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (process.env["SELENIUM_WINDOW_HEIGHT"] != null)
|
|
105
|
+
{
|
|
106
|
+
createWindowSize ();
|
|
107
|
+
this.windowSize.height = parseFloat (process.env["SELENIUM_WINDOW_HEIGHT"]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.remoteServer !== "")
|
|
111
|
+
{
|
|
112
|
+
builder = builder.usingServer (this.remoteServer);
|
|
113
|
+
createWindowSize ();
|
|
114
|
+
this.headless = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.browser === "firefox")
|
|
118
|
+
{
|
|
119
|
+
let options = new firefox.Options ();
|
|
120
|
+
|
|
121
|
+
if (this.openDevTools === true)
|
|
122
|
+
options = options.addArguments ("-devtools");
|
|
123
|
+
|
|
124
|
+
if (this.headless === true)
|
|
125
|
+
options = options.headless ();
|
|
126
|
+
|
|
127
|
+
if (this.windowSize != null)
|
|
128
|
+
options = options.windowSize (this.windowSize);
|
|
129
|
+
|
|
130
|
+
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED != null)
|
|
131
|
+
{
|
|
132
|
+
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED == "0")
|
|
133
|
+
options.setAcceptInsecureCerts (true);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
builder = builder.setFirefoxOptions (options);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.browser === "chrome")
|
|
140
|
+
{
|
|
141
|
+
let options = new chrome.Options ();
|
|
142
|
+
|
|
143
|
+
options = options.addArguments ("--disable-gpu", "--no-sandbox");
|
|
144
|
+
if (this.openDevTools === true)
|
|
145
|
+
options = options.addArguments ("--auto-open-devtools-for-tabs");
|
|
146
|
+
|
|
147
|
+
if (this.headless === true)
|
|
148
|
+
options = options.headless ();
|
|
149
|
+
|
|
150
|
+
if (this.windowSize != null)
|
|
151
|
+
options = options.windowSize (this.windowSize);
|
|
152
|
+
|
|
153
|
+
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED != null)
|
|
154
|
+
{
|
|
155
|
+
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED == "0")
|
|
156
|
+
options.setAcceptInsecureCerts (true);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
builder = builder.setChromeOptions (options);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.driver = await builder.build ();
|
|
163
|
+
this.session = await this.driver.getSession ();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get a test object by it's name. If a * is used, it will be used as a
|
|
168
|
+
* wildcard for the object's name. If a > is used, then the name will
|
|
169
|
+
* be treated as a CSS selector.
|
|
170
|
+
*/
|
|
171
|
+
getTestObjectByName (name: string): By
|
|
172
|
+
{
|
|
173
|
+
let selector: string = this.parseTestObject (name);
|
|
174
|
+
|
|
175
|
+
return (By.css (selector));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Navigate to a url.
|
|
180
|
+
*/
|
|
181
|
+
async navigateToUrl(url: string): Promise<void>
|
|
182
|
+
{
|
|
183
|
+
await this.driver.get (url);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Wait for a test element using Selenium Webdriver.
|
|
188
|
+
*/
|
|
189
|
+
async waitForTestElement (name: string | HotTestElement,
|
|
190
|
+
options: HotTestElementOptions = new HotTestElementOptions ()): Promise<WebElement>
|
|
191
|
+
{
|
|
192
|
+
let nameStr: string = "";
|
|
193
|
+
|
|
194
|
+
if (typeof (name) === "string")
|
|
195
|
+
nameStr = name;
|
|
196
|
+
else
|
|
197
|
+
nameStr = name.name;
|
|
198
|
+
|
|
199
|
+
let foundElm: WebElement = null;
|
|
200
|
+
|
|
201
|
+
if (options.mustBeVisible === false)
|
|
202
|
+
foundElm = await this.driver.wait (until.elementLocated (this.getTestObjectByName (nameStr)));
|
|
203
|
+
else
|
|
204
|
+
{
|
|
205
|
+
let elms: WebElement[] = await this.driver.wait (until.elementsLocated (this.getTestObjectByName (nameStr)));
|
|
206
|
+
|
|
207
|
+
for (let iIdx = 0; iIdx < elms.length; iIdx++)
|
|
208
|
+
{
|
|
209
|
+
let elm: WebElement = elms[iIdx];
|
|
210
|
+
|
|
211
|
+
if (await elm.isDisplayed () === true)
|
|
212
|
+
{
|
|
213
|
+
foundElm = elm;
|
|
214
|
+
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return (foundElm);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Get a test element using selenium webdriver.
|
|
225
|
+
*/
|
|
226
|
+
async findTestElement (name: string | HotTestElement,
|
|
227
|
+
options: HotTestElementOptions = new HotTestElementOptions ()): Promise<WebElement>
|
|
228
|
+
{
|
|
229
|
+
let nameStr: string = "";
|
|
230
|
+
|
|
231
|
+
if (typeof (name) === "string")
|
|
232
|
+
nameStr = name;
|
|
233
|
+
else
|
|
234
|
+
nameStr = name.name;
|
|
235
|
+
|
|
236
|
+
let foundElm: WebElement = null;
|
|
237
|
+
|
|
238
|
+
if (options.mustBeVisible === false)
|
|
239
|
+
{
|
|
240
|
+
let elms: WebElement[] = await this.driver.findElements (this.getTestObjectByName (nameStr));
|
|
241
|
+
|
|
242
|
+
if (elms.length > 0)
|
|
243
|
+
foundElm = elms[0];
|
|
244
|
+
}
|
|
245
|
+
else
|
|
246
|
+
{
|
|
247
|
+
let elms: WebElement[] = await this.driver.findElements (this.getTestObjectByName (nameStr));
|
|
248
|
+
|
|
249
|
+
for (let iIdx = 0; iIdx < elms.length; iIdx++)
|
|
250
|
+
{
|
|
251
|
+
let elm: WebElement = elms[iIdx];
|
|
252
|
+
|
|
253
|
+
if (await elm.isDisplayed () === true)
|
|
254
|
+
{
|
|
255
|
+
foundElm = elm;
|
|
256
|
+
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return (foundElm);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Run a command using Selenium Webdriver.
|
|
267
|
+
*/
|
|
268
|
+
async runCommand (testElm: string | HotTestElement, funcName: string = "",
|
|
269
|
+
valueStr: string = "",
|
|
270
|
+
options: HotTestElementOptions = new HotTestElementOptions ()): Promise<any>
|
|
271
|
+
{
|
|
272
|
+
let name: string = "";
|
|
273
|
+
let func: string = "";
|
|
274
|
+
let value: string = "";
|
|
275
|
+
|
|
276
|
+
if (typeof (testElm) !== "string")
|
|
277
|
+
{
|
|
278
|
+
name = testElm.name;
|
|
279
|
+
func = testElm.func;
|
|
280
|
+
value = testElm.value;
|
|
281
|
+
}
|
|
282
|
+
else
|
|
283
|
+
{
|
|
284
|
+
name = testElm;
|
|
285
|
+
func = funcName;
|
|
286
|
+
value = valueStr;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
let elm: WebElement = await this.findTestElement (name, options);
|
|
290
|
+
let result: any = null;
|
|
291
|
+
|
|
292
|
+
if (elm == null)
|
|
293
|
+
{
|
|
294
|
+
if (options.ignoreMissingElementError === true)
|
|
295
|
+
return (result);
|
|
296
|
+
|
|
297
|
+
throw new Error (`HotTestSeleniumDriver: Unable to find test element ${name}!`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (func != null)
|
|
301
|
+
{
|
|
302
|
+
if (func !== "")
|
|
303
|
+
{
|
|
304
|
+
if (value != null)
|
|
305
|
+
{
|
|
306
|
+
/// @ts-ignore
|
|
307
|
+
result = await elm[func] (value);
|
|
308
|
+
}
|
|
309
|
+
else
|
|
310
|
+
{
|
|
311
|
+
/// @ts-ignore
|
|
312
|
+
result = await elm[func] ();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return (result);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* An expression to test.
|
|
322
|
+
*/
|
|
323
|
+
async assertElementValue (name: string | HotTestElement, value: any,
|
|
324
|
+
errorMessage: string = "",
|
|
325
|
+
options: HotTestElementOptions = new HotTestElementOptions ()): Promise<any>
|
|
326
|
+
{
|
|
327
|
+
let elm: WebElement = await this.findTestElement (name, options);
|
|
328
|
+
|
|
329
|
+
if (elm == null)
|
|
330
|
+
{
|
|
331
|
+
let realName: string = "";
|
|
332
|
+
|
|
333
|
+
if (typeof (name) === "string")
|
|
334
|
+
realName = name;
|
|
335
|
+
else
|
|
336
|
+
realName = name.name;
|
|
337
|
+
|
|
338
|
+
if (options.ignoreMissingElementError === true)
|
|
339
|
+
return;
|
|
340
|
+
|
|
341
|
+
throw new Error (`Unable to find test object ${realName}`);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let elmValue: string = await elm.getText ();
|
|
345
|
+
let elmValue2: string = "";
|
|
346
|
+
let elmValue3: string = "";
|
|
347
|
+
let finalElmValue: string = elmValue;
|
|
348
|
+
|
|
349
|
+
if (finalElmValue === "")
|
|
350
|
+
{
|
|
351
|
+
elmValue2 = await elm.getAttribute ("value");
|
|
352
|
+
|
|
353
|
+
if (elmValue2 != null)
|
|
354
|
+
{
|
|
355
|
+
if (elmValue2 !== "")
|
|
356
|
+
finalElmValue = elmValue2;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (finalElmValue === "")
|
|
361
|
+
{
|
|
362
|
+
elmValue3 = await elm.getAttribute ("innerHTML");
|
|
363
|
+
|
|
364
|
+
if (elmValue3 != null)
|
|
365
|
+
{
|
|
366
|
+
if (elmValue3 !== "")
|
|
367
|
+
finalElmValue = elmValue3;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (finalElmValue != value)
|
|
372
|
+
throw new Error (`Error: ${errorMessage}. Expected: ${JSON.stringify (value)}, Actual: ${JSON.stringify (finalElmValue)}`);
|
|
373
|
+
}
|
|
374
|
+
}
|