1
+ const { actor, Helper, locator} = require ( 'codeceptjs' ) ;
2
+ const I = actor ( ) ;
3
+
4
+ let dynamicLocators = {
5
+ validateText : ( text ) => `//*[text()="${ text } "] | //*[@value="${ text } "]` ,
6
+ selectRadioButton : ( text ) => `//input[@value="${ text } "]` ,
7
+ fillTextBox : ( text ) => `//input[@name="${ text } "]` ,
8
+ checkBoxSelect : ( text ) => `//label[text()="${ text } "]/..//input`
9
+ }
10
+
11
+ class ui_test_scenario_page extends Helper {
12
+ constructor ( config ) {
13
+ super ( config ) ;
14
+ this . validateIOnLoginAndSignupPageLocator = `//h2[text()="New User Signup!"]` ;
15
+ this . fillNameLocator = `//input[@name="name"]` ;
16
+ this . fillEmailLocator = `(//input[@name="email"])[2]` ;
17
+ }
18
+
19
+ async validateIOnLoginAndSignupPage ( ) {
20
+ await common_codeceptjs_utils . waitAndSee ( this . validateIOnLoginAndSignupPageLocator ) ;
21
+ }
22
+
23
+ async fillNameAndEmail ( name , email ) {
24
+ await common_codeceptjs_utils . waitAndFillField ( this . fillNameLocator , name ) ;
25
+ await common_codeceptjs_utils . waitAndFillField ( this . fillEmailLocator , email ) ;
26
+ }
27
+
28
+ async fillAndValidateUserDetails ( ) {
29
+ const data = test_data . signup_test_data ;
30
+ const AddressInformation = data . AddressInformation ;
31
+ await common_codeceptjs_utils . waitAndSee ( dynamicLocators . validateText ( "Enter Account Information" ) ) ;
32
+ await common_codeceptjs_utils . waitAndClick ( dynamicLocators . selectRadioButton ( data . title ) ) ;
33
+ await common_codeceptjs_utils . waitAndSee ( dynamicLocators . validateText ( data . Name ) ) ;
34
+ await common_codeceptjs_utils . waitAndSee ( dynamicLocators . validateText ( data . Email ) ) ;
35
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( "password" ) , data . Password ) ;
36
+ await I . selectOption ( 'days' , data . dateOfBirth . day ) ;
37
+ await I . selectOption ( 'months' , data . dateOfBirth . month ) ;
38
+ await I . selectOption ( 'years' , data . dateOfBirth . year ) ;
39
+ await common_codeceptjs_utils . waitAndChecked ( dynamicLocators . checkBoxSelect ( "Sign up for our newsletter!" ) ) ;
40
+ await common_codeceptjs_utils . waitAndChecked ( dynamicLocators . checkBoxSelect ( "Receive special offers from our partners!" ) ) ;
41
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'first_name' ) , AddressInformation . firstName ) ;
42
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'last_name' ) , AddressInformation . lastName ) ;
43
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'company' ) , AddressInformation . company ) ;
44
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'address1' ) , AddressInformation . addressLine1 ) ;
45
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'address2' ) , AddressInformation . addressLine2 ) ;
46
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'state' ) , AddressInformation . state ) ;
47
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'city' ) , AddressInformation . city ) ;
48
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'zipcode' ) , AddressInformation . zipcode ) ;
49
+ await common_codeceptjs_utils . waitAndFillField ( dynamicLocators . fillTextBox ( 'mobile_number' ) , AddressInformation . mobileNumber ) ;
50
+ }
51
+ }
52
+
53
+ module . exports = new ui_test_scenario_page ( ) ;
0 commit comments