1
1
const webdriver = require ( 'selenium-webdriver' ) ;
2
2
const { By, until } = webdriver ;
3
3
4
- ( async function ( ) {
4
+ async function localHostedTest ( driver , servType , dbType , dbUri , dbName , dbDesc ) {
5
+ await driver . findElement ( By . id ( 'serv-type' ) ) . sendKeys ( servType ) ;
6
+ await driver . findElement ( By . id ( 'db-type' ) ) . sendKeys ( dbType ) ;
7
+ await driver . findElement ( By . id ( 'db-uri' ) ) . sendKeys ( dbUri ) ;
8
+ await driver . findElement ( By . id ( 'db-name' ) ) . sendKeys ( dbName ) ;
9
+ await driver . findElement ( By . id ( 'db-desc' ) ) . sendKeys ( dbDesc ) ;
10
+ await driver . findElement ( By . xpath ( '//button[text()="Submit"]' ) ) . click ( ) ;
11
+ }
12
+
13
+ async function cloudHostedTest (
14
+ driver ,
15
+ servType ,
16
+ awsInstance ,
17
+ awsRegion ,
18
+ awsAccessKey ,
19
+ awsSecretAccessKey ,
20
+ awsURL ,
21
+ awsName ,
22
+ dbDesc
23
+ ) {
24
+ await driver . findElement ( By . id ( 'serv-type' ) ) . sendKeys ( servType ) ;
25
+ await driver . findElement ( By . id ( 'aws-instance' ) ) . sendKeys ( awsInstance ) ;
26
+ await driver . findElement ( By . id ( 'aws-region' ) ) . sendKeys ( awsRegion ) ;
27
+ await driver . findElement ( By . id ( 'aws-access-key' ) ) . sendKeys ( awsAccessKey ) ;
28
+ await driver . findElement ( By . id ( 'aws-secret-access-key' ) ) . sendKeys ( awsSecretAccessKey ) ;
29
+ await driver . findElement ( By . id ( 'aws-url' ) ) . sendKeys ( awsURL ) ;
30
+ await driver . findElement ( By . id ( 'aws-name' ) ) . sendKeys ( awsName ) ;
31
+ await driver . findElement ( By . id ( 'db-desc' ) ) . sendKeys ( dbDesc ) ;
32
+ await driver . findElement ( By . xpath ( '//button[text()="Submit"]' ) ) . click ( ) ;
33
+ }
34
+
35
+ async function signupTest ( driver , username , email , password , passwordConfirm ) {
36
+ await driver . wait ( until . elementLocated ( By . className ( 'main-routes' ) ) , 30000 ) ;
37
+ await driver . findElement ( By . id ( 'username' ) ) . sendKeys ( username ) ;
38
+ await driver . findElement ( By . id ( 'email' ) ) . sendKeys ( email ) ;
39
+ await driver . findElement ( By . id ( 'password' ) ) . sendKeys ( password ) ;
40
+ await driver . findElement ( By . id ( 'passwordConfirm' ) ) . sendKeys ( passwordConfirm ) ;
41
+ await driver . findElement ( By . xpath ( '//button[text()="Sign Up"]' ) ) . click ( ) ;
42
+ }
43
+
44
+ ( async function ( ) {
5
45
const driver = new webdriver . Builder ( )
6
46
. usingServer ( 'http://localhost:9515' )
7
47
. withCapabilities ( {
8
48
'goog:chromeOptions' : {
9
49
debuggerAddress : 'localhost:9222' ,
10
- }
50
+ } ,
11
51
} )
12
52
. forBrowser ( 'chrome' )
13
53
. build ( ) ;
@@ -17,20 +57,59 @@ const { By, until } = webdriver;
17
57
await driver . findElement ( By . className ( 'card' ) ) . click ( ) ;
18
58
await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
19
59
await driver . findElement ( By . className ( 'env-button2' ) ) . click ( ) ;
20
- await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
60
+ await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
61
+ await localHostedTest (
62
+ driver ,
63
+ 'Docker' ,
64
+ 'SQL' ,
65
+ 'mongodb://localhost:27017/mydb' ,
66
+ 'Test Docker' ,
67
+ 'A description of my app'
68
+ ) ;
69
+
70
+ await driver . findElement ( By . id ( 'card-add' ) ) . click ( ) ;
71
+ await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
72
+ await driver . findElement ( By . className ( 'env-button2' ) ) . click ( ) ;
73
+ await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
74
+ await localHostedTest (
75
+ driver ,
76
+ 'Kubernetes' ,
77
+ 'MongoDB' ,
78
+ 'mongodb://localhost:27017/mydb' ,
79
+ 'Test Kubernetes' ,
80
+ 'A description of my app'
81
+ ) ;
82
+
83
+ await driver . findElement ( By . id ( 'card-add' ) ) . click ( ) ;
84
+ await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
85
+ await driver . findElement ( By . className ( 'env-button' ) ) . click ( ) ;
86
+ await driver . wait ( until . elementLocated ( By . className ( 'add-container' ) ) , 10000 ) ;
87
+ await cloudHostedTest (
88
+ driver ,
89
+ 'Elastic Compute Cloud (EC2)' ,
90
+ 'i-1234567890abcdef0' ,
91
+ 'us-east-1' ,
92
+ 'your-access-key' ,
93
+ 'your-secret-access-key' ,
94
+ 'mongodb://your-mongodb-url' ,
95
+ 'Test AWS' ,
96
+ 'Test MongoDB Database'
97
+ ) ;
21
98
22
- await driver . findElement ( By . id ( 'serv-type' ) ) . sendKeys ( 'Docker' ) ;
23
- await driver . findElement ( By . id ( 'db-type' ) ) . sendKeys ( 'SQL' ) ;
24
- await driver . findElement ( By . id ( 'db-uri' ) ) . sendKeys ( 'mongodb://localhost:27017/mydb' ) ;
25
- await driver . findElement ( By . id ( 'db-name' ) ) . sendKeys ( 'My App' ) ;
26
- await driver . findElement ( By . id ( 'db-desc' ) ) . sendKeys ( 'A description of my app' ) ;
99
+ await driver . findElement ( By . className ( 'personIconArea' ) ) . click ( ) ;
100
+ const signUpButton = await driver . wait (
101
+ until . elementLocated ( By . xpath ( '//span[text()="Sign Up"]' ) ) ,
102
+ 10000
103
+ ) ;
104
+ await driver . wait ( until . elementIsEnabled ( signUpButton ) , 10000 ) ;
105
+ await signUpButton . click ( ) ;
106
+ await signupTest ( driver , 'testUser' , '[email protected] ' , 'testPassword' , 'testPassword' ) ;
27
107
28
- await driver . findElement ( By . xpath ( '//button[text()="Submit"]' ) ) . click ( ) ;
29
108
console . log ( 'E2E test completed successfully' ) ;
30
-
31
109
} catch ( error ) {
32
110
console . error ( 'E2E test failed:' , error ) ;
33
111
} finally {
112
+ await driver . executeScript ( 'window.close()' ) ;
34
113
await driver . quit ( ) ;
35
114
}
36
115
} ) ( ) ;
0 commit comments