@@ -7,6 +7,7 @@ const http = require('http')
7
7
const https = require ( 'https' )
8
8
const assert = require ( 'assert' ) ;
9
9
const { CryptoJS } = nodeCryptoJs ;
10
+ const mnemonicWords = require ( "../fixtures/mnemonic.json" )
10
11
11
12
const { testnetMasternode, testnetBlockService } = config ;
12
13
@@ -34,7 +35,8 @@ const switchWindow = async (driver, windowNum) => {
34
35
35
36
const gotoAccountsPage = async ( driver ) => {
36
37
await sleep ( 1000 , true )
37
- await driver . findElement ( By . id ( 'accounts' ) ) . click ( ) ;
38
+ let element = driver . findElement ( By . id ( 'accounts' ) )
39
+ await driver . executeScript ( "arguments[0].click();" , element )
38
40
}
39
41
40
42
const completeFirstRunSetup = async ( driver , walletPassword , lock = true , testnet = true ) => {
@@ -43,9 +45,39 @@ const completeFirstRunSetup = async (driver, walletPassword, lock = true, testne
43
45
await driver . executeScript ( `document.getElementById('pwd1').value='${ walletPassword } '` ) ;
44
46
await driver . executeScript ( `document.getElementById('pwd2').value='${ walletPassword } '` ) ;
45
47
await driver . findElement ( By . id ( 'save-pwd' ) ) . click ( )
48
+ await sleep ( 2000 )
49
+
50
+ let elements = await driver . findElements ( By . css ( '.mnemonic .cell input' ) )
51
+
52
+ let vals ;
53
+ let words = [ ] ;
54
+ elements . forEach ( element => {
55
+ let value = element . getAttribute ( "value" ) ;
56
+ words . push ( value ) ;
57
+ } ) ;
58
+ await Promise . all ( words ) . then ( ( res ) => {
59
+ vals = res ; ;
60
+ } )
61
+ await driver . findElement ( By . css ( '.chk-checkmark' ) ) . click ( ) ;
62
+ await driver . findElement ( By . id ( 'next' ) ) . click ( ) ;
63
+ await sleep ( 3000 ) ;
64
+
65
+ elements = await driver . findElements ( By . css ( '.mnemonic .cell input' ) ) ;
66
+ for ( let i = 0 ; i < 24 ; i ++ ) {
67
+ try {
68
+ await elements [ i ] . sendKeys ( `${ vals [ i ] } \n` ) ;
69
+ } catch {
70
+ // tbd
71
+ }
72
+ }
73
+ await driver . findElement ( By . id ( 'next' ) ) . click ( ) ;
74
+ await sleep ( 2000 )
75
+
76
+ await driver . findElement ( By . css ( '.chk-checkmark' ) ) . click ( ) ;
46
77
await driver . findElement ( By . id ( 'i-understand' ) ) . click ( )
47
- await sleep ( 5000 )
48
- await ignoreBackupModal ( driver )
78
+ await sleep ( 3000 )
79
+
80
+ // await ignoreBackupModal(driver)
49
81
if ( testnet ) await changeToTestnet ( driver )
50
82
await driver . findElement ( By . id ( 'refresh-icon' ) ) . click ( )
51
83
await sleep ( 3000 , true )
@@ -55,8 +87,8 @@ const completeFirstRunSetup = async (driver, walletPassword, lock = true, testne
55
87
}
56
88
57
89
const ignoreBackupModal = async ( driver ) => {
58
- await validBackupModal ( driver )
59
- await driver . findElement ( By . id ( ' ignore-btn' ) ) . click ( ) ;
90
+ // await validBackupModal(driver)
91
+ await driver . wait ( until . elementLocated ( By . id ( ` ignore-btn` ) ) , 25000 ) . click ( ) ;
60
92
await sleep ( 1000 , true )
61
93
}
62
94
@@ -66,24 +98,30 @@ const completeFirstRunSetupRestore = async (driver, workingDir, walletInfo, lock
66
98
await driver . executeScript ( `document.getElementById('pwd1').value='${ walletInfo . walletPassword } '` ) ;
67
99
await driver . executeScript ( `document.getElementById('pwd2').value='${ walletInfo . walletPassword } '` ) ;
68
100
await driver . findElement ( By . id ( 'save-pwd' ) ) . click ( )
69
- await driver . findElement ( By . id ( 'filePicker' ) ) . sendKeys ( path . join ( workingDir , walletInfo . keystoreInfo . file ) )
70
- await driver . findElement ( By . id ( 'confirm-keystore-btn' ) ) . click ( )
71
101
await sleep ( 2000 )
72
- await driver . executeScript ( `document.getElementById('pwd-input').value='${ walletInfo . keystoreInfo . password } '` )
73
- await driver . findElement ( By . id ( 'pwd-btn' ) ) . click ( )
102
+
103
+ let words = mnemonicWords . mnemonic . split ( ' ' ) ;
104
+ let elements = await driver . findElements ( By . css ( '.mnemonic .cell input' ) ) ;
105
+ for ( let i = 0 ; i < 24 ; i ++ ) {
106
+ await elements [ i ] . sendKeys ( `${ words [ i ] } \n` ) ;
107
+ }
108
+ await driver . findElement ( By . id ( 'next' ) ) . click ( ) ;
109
+ await sleep ( 2000 )
110
+
74
111
await driver . executeScript ( `document.getElementById('chk-all').innerText='testing'` )
75
112
await driver . findElement ( By . id ( 'chk-all' ) ) . click ( )
76
113
await driver . findElement ( By . id ( 'restore-btn' ) ) . click ( )
77
114
await sleep ( 2000 )
78
115
await driver . findElement ( By . id ( 'home-btn' ) ) . click ( )
79
- await sleep ( 4000 )
116
+ await sleep ( 3000 )
117
+ // await driver.findElement(By.id('ignore-btn')).click()
80
118
await ignoreBackupModal ( driver )
81
119
if ( testnet ) {
82
120
await changeToTestnet ( driver )
83
121
await sleep ( 2000 )
84
122
}
85
123
await driver . findElement ( By . id ( 'refresh-icon' ) ) . click ( )
86
- await sleep ( 6000 , true )
124
+ await sleep ( 3000 , true )
87
125
if ( lock ) {
88
126
await driver . findElement ( By . id ( 'lock' ) ) . click ( )
89
127
}
@@ -107,7 +145,8 @@ const lockWallet = async (driver, switchback) => {
107
145
await sleep ( 1000 , true )
108
146
}
109
147
const changeToTestnet = async ( driver ) => {
110
- let navNetwork = await driver . wait ( until . elementLocated ( By . id ( "nav-network-info" ) ) , 5000 ) ;
148
+ await driver . wait ( until . elementLocated ( By . id ( 'nav-network-currently-selected' ) ) , 5000 ) . click ( ) ;
149
+ let navNetwork = await driver . wait ( until . elementLocated ( By . id ( "select-option-1" ) ) , 5000 ) ;
111
150
navNetwork . click ( )
112
151
await sleep ( 2000 , true )
113
152
}
@@ -116,7 +155,7 @@ const setAsTrustedDapp = async (driver) => {
116
155
await sleep ( 500 , true )
117
156
await driver . findElement ( By . id ( "dapp-connections" ) ) . click ( )
118
157
await driver . wait ( until . elementLocated ( By . id ( "dapp-appname-0" ) ) , 5000 ) . click ( )
119
- await sleep ( 500 , true )
158
+ await sleep ( 1000 , true )
120
159
await driver . findElement ( By . id ( "modify-dapp-btn" ) ) . click ( )
121
160
await sleep ( 500 , true )
122
161
await driver . findElement ( By . id ( "preapproval-btn" ) ) . click ( )
@@ -154,6 +193,7 @@ const approvePopup = async (driver, popupWindow, switchback, trusted = true) =>
154
193
await accountLink_Button . click ( )
155
194
156
195
if ( ! trusted ) {
196
+ await sleep ( 1000 )
157
197
let trusted_Radio = await driver . wait ( until . elementLocated ( By . id ( "not-trusted" ) ) , 5000 ) ;
158
198
await trusted_Radio . click ( )
159
199
}
@@ -346,7 +386,7 @@ const setupMetamask = async (driver, kovan = true) => {
346
386
await driver . findElement ( By . xpath ( "//button[contains(text(),'No Thanks')]" ) ) . click ( )
347
387
await sleep ( 1000 )
348
388
349
- await driver . findElement ( By . xpath ( "//input[@placeholder='Paste seed phrase from clipboard']" ) ) . sendKeys ( config . metamaskBackupPhrase )
389
+ await driver . findElement ( By . xpath ( "//input[@placeholder='Paste Recovery Phrase from clipboard']" ) ) . sendKeys ( config . metamaskBackupPhrase )
350
390
await driver . findElement ( By . id ( "password" ) ) . sendKeys ( config . metamaskPassword )
351
391
await driver . findElement ( By . id ( "confirm-password" ) ) . sendKeys ( config . metamaskPassword )
352
392
await driver . findElement ( By . className ( "first-time-flow__terms" ) ) . click ( )
@@ -387,7 +427,7 @@ const addAccount = async (driver) => {
387
427
await driver . findElement ( By . css ( '.submit-button' ) ) . click ( ) ;
388
428
let messageField = await driver . wait ( until . elementLocated ( By . id ( `message-text` ) ) , 25000 ) ;
389
429
let message = await messageField . getAttribute ( "innerText" )
390
- assert . equal ( message , `Added New Lamden Account to your wallet ` ) ;
430
+ assert . equal ( message , `Added New Tau Account to your Lamden Vault ` ) ;
391
431
await driver . findElement ( By . id ( "home-btn" ) ) . click ( )
392
432
await sleep ( 500 , true )
393
433
await ignoreBackupModal ( driver )
@@ -401,7 +441,7 @@ const addTrackedAccount = async (driver, address) => {
401
441
await driver . findElement ( By . css ( '.submit-button' ) ) . click ( ) ;
402
442
let messageField = await driver . wait ( until . elementLocated ( By . id ( `message-text` ) ) , 25000 ) ;
403
443
let message = await messageField . getAttribute ( "innerText" )
404
- assert . equal ( message , `Added New Lamden Account to your wallet ` ) ;
444
+ assert . equal ( message , `Added New Tau Account to your Lamden Vault ` ) ;
405
445
await driver . findElement ( By . id ( "home-btn" ) ) . click ( )
406
446
await sleep ( 500 , true )
407
447
let emts = await driver . findElements ( By . className ( "notification" ) )
@@ -419,6 +459,49 @@ const changePassword = async (driver, oldpd, newpd, confirmpd) => {
419
459
await driver . findElement ( By . id ( "change-pw-btn" ) ) . click ( ) ;
420
460
}
421
461
462
+ const gotoNetwork = async ( driver ) => {
463
+ await sleep ( 500 )
464
+ await driver . findElement ( By . id ( "settings" ) ) . click ( ) ;
465
+ await driver . findElement ( By . id ( "networks-btn" ) ) . click ( ) ;
466
+ await sleep ( 500 )
467
+ }
468
+
469
+ const clearNetwork = async ( driver ) => {
470
+ await driver . findElement ( By . id ( "name" ) ) . clear ( ) ;
471
+ await driver . findElement ( By . id ( "currencySymbol" ) ) . clear ( ) ;
472
+ await driver . findElements ( By . css ( "#mainbox-hostlist>div>.text-btn" ) ) . then ( res => {
473
+ res . forEach ( async item => {
474
+ await driver . executeScript ( `arguments[0].style.display = 'inline-block'` , item )
475
+ await item . click ( )
476
+ } ) ;
477
+ } )
478
+ await driver . findElements ( By . css ( "#mainbox-blockServiceList>div>.text-btn" ) ) . then ( res => {
479
+
480
+ res . forEach ( async item => {
481
+ await driver . executeScript ( `arguments[0].style.display = 'inline-block'` , item )
482
+ await item . click ( )
483
+ } ) ;
484
+ } )
485
+ await driver . findElement ( By . id ( "explorer" ) ) . clear ( ) ;
486
+ }
487
+
488
+ const fillNetworkForm = async ( driver , networkinfo ) => {
489
+ await driver . findElement ( By . id ( "name" ) ) . sendKeys ( networkinfo . name ) ;
490
+ await driver . findElement ( By . id ( "currencySymbol" ) ) . sendKeys ( networkinfo . currencySymbol ) ;
491
+
492
+ let hostinput = await driver . findElement ( By . id ( "hostlist" ) )
493
+ await hostinput . sendKeys ( networkinfo . host )
494
+ await driver . findElement ( By . css ( "#hostlist + .add-btn" ) ) . click ( )
495
+
496
+ let blockserviceInput = await driver . findElement ( By . id ( "blockServiceList" ) )
497
+ await blockserviceInput . sendKeys ( networkinfo . blockservice )
498
+ await driver . findElement ( By . css ( "#blockServiceList + .add-btn" ) ) . click ( )
499
+
500
+ if ( networkinfo . explorer ) {
501
+ await driver . findElement ( By . id ( "explorer" ) ) . sendKeys ( networkinfo . explorer ) ;
502
+ }
503
+ }
504
+
422
505
module . exports = {
423
506
changePassword,
424
507
sleep,
@@ -440,5 +523,8 @@ module.exports = {
440
523
ignoreBackupModal,
441
524
validBackupModal,
442
525
addAccount,
443
- addTrackedAccount
526
+ addTrackedAccount,
527
+ gotoNetwork,
528
+ clearNetwork,
529
+ fillNetworkForm
444
530
}
0 commit comments