1414 */
1515class HomePage extends TypifiedPage {
1616
17- /**
18- *
19- * @var WebElement
20- * @find-by('name' => 'u.login-sidebox[-2][UserLogin]')
21- */
22- protected $ usernameInput ;
23-
2417 /**
2518 *
2619 * @var WebElement
@@ -44,6 +37,20 @@ class HomePage extends TypifiedPage {
4437 */
4538 protected $ radioGroup ;
4639
40+ /**
41+ *
42+ * @var WebElement
43+ * @find-by('name' => 'u.login-sidebox[-2][UserLogin]')
44+ */
45+ protected $ usernameInput ;
46+
47+ /**
48+ *
49+ * @var WebElement
50+ * @find-by('name' => 'u.login-sidebox[-2][UserPassword]')
51+ */
52+ protected $ passwordInput ;
53+
4754 /**
4855 * Login Button
4956 *
@@ -74,34 +81,112 @@ class HomePage extends TypifiedPage {
7481 */
7582 protected $ myTest = '' ;
7683
77- public function examplePageMethod ()
84+ /**
85+ * Changes currency.
86+ *
87+ * @param string $currency_code Currency code.
88+ *
89+ * @return void
90+ */
91+ public function changeCurrency ($ currency_code )
7892 {
79- // $this->currencyDropdown->setValue('EUR' );
80- $ this -> languageDropdown -> selectByVisibleText ( ' Russian ' );
93+ $ this ->currencyDropdown ->setValue ($ currency_code );
94+ }
8195
96+ /**
97+ * Changes language.
98+ *
99+ * @param string $language_title Language title.
100+ *
101+ * @return void
102+ */
103+ public function changeLanguage ($ language_title )
104+ {
105+ $ this ->languageDropdown ->selectByText ($ language_title );
106+ }
107+
108+ /**
109+ * Returns radio button collection.
110+ *
111+ * @return RadioGroup
112+ */
113+ public function getRadioGroup ()
114+ {
82115 // Need `getObject` to iterate over current collection in proxy and not a list of collection.
83- foreach ( $ this ->radioGroup ->getObject () as $ radioButton ) {
84- if ( $ radioButton ->isSelected () ) {
85- echo 'yes ' ;
86- }
87- }
116+ return $ this ->radioGroup ->getObject ();
117+ }
88118
89- $ this ->radioGroup ->selectButtonByValue (4 );
119+ /**
120+ * Selects radio button by value.
121+ *
122+ * @param mixed $value Value.
123+ *
124+ * @return void
125+ */
126+ public function selectRadioButton ($ value )
127+ {
128+ $ this ->radioGroup ->selectButtonByValue ($ value );
129+ }
90130
91- // inline login
92- $ this ->usernameInput ->setValue ('user-a ' );
131+ /**
132+ * Performs login using elements declared inline.
133+ *
134+ * @param string $username Username.
135+ * @param string $password Password.
136+ *
137+ * @return void
138+ */
139+ public function loginInline ($ username , $ password )
140+ {
141+ $ this ->usernameInput ->setValue ($ username );
142+ $ this ->passwordInput ->setValue ($ password );
93143 $ this ->loginButton ->click ();
144+ }
94145
95- // html block login
96- $ error_message = $ this ->loginSidebox ->login ('user-b ' , 'password-b ' )->getLoginErrorMessage ();
146+ /**
147+ * Performs login using elements from sidebox.
148+ *
149+ * @param string $username Username.
150+ * @param string $password Password.
151+ *
152+ * @return string
153+ */
154+ public function loginViaSidebox ($ username , $ password )
155+ {
156+ return $ this ->loginSidebox ->login ($ username , $ password )->getLoginErrorMessage ();
157+ }
97158
98- // nested html block login
99- $ error_message = $ this ->sidebar ->login ('user-b ' , 'password-b ' );
159+ /**
160+ * Performs login using elements sidebar, that uses sidebox.
161+ *
162+ * @param string $username Username.
163+ * @param string $password Password.
164+ *
165+ * @return string
166+ */
167+ public function loginViaSidebar ($ username , $ password )
168+ {
169+ return $ this ->sidebar ->login ($ username , $ password );
170+ }
100171
101- // auto-generated name
102- echo $ this ->sidebar ->getName ();
172+ /**
173+ * Returns auto-generated name of the element.
174+ *
175+ * @return string
176+ */
177+ public function getAutoGeneratedElementName ()
178+ {
179+ return $ this ->sidebar ->getName ();
180+ }
103181
104- // override name
105- echo $ this ->loginSidebox ->getName ();
182+ /**
183+ * Returns overridden name of the element.
184+ *
185+ * @return string
186+ */
187+ public function getOverrideElementName ()
188+ {
189+ return $ this ->loginSidebox ->getName ();
106190 }
191+
107192}
0 commit comments