1 | <?php |
||
2 | |||
3 | namespace DigitalOrigin\Pmt\Test\Common; |
||
4 | |||
5 | use DigitalOrigin\Pmt\Test\PaylaterMagentoTest; |
||
6 | use Facebook\WebDriver\WebDriver; |
||
7 | use Facebook\WebDriver\WebDriverBy; |
||
8 | use Facebook\WebDriver\WebDriverExpectedCondition; |
||
9 | use PagaMasTarde\SeleniumFormUtils\SeleniumHelper; |
||
10 | |||
11 | /** |
||
12 | * Class AbstractMg21Selenium |
||
13 | * @package DigitalOrigin\Test\Common |
||
14 | */ |
||
15 | abstract class AbstractMg21Selenium extends PaylaterMagentoTest |
||
16 | { |
||
17 | /** |
||
18 | * @throws \Exception |
||
19 | */ |
||
20 | public function loginToBackOffice() |
||
21 | { |
||
22 | $this->webDriver->get(self::MAGENTO_URL.self::BACKOFFICE_FOLDER); |
||
23 | $emailElementSearch = WebDriverBy::id('username'); |
||
24 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($emailElementSearch); |
||
25 | $this->webDriver->wait()->until($condition); |
||
26 | $this->findById('username')->clear()->sendKeys($this->configuration['backofficeUsername']); |
||
27 | $this->findById('login')->clear()->sendKeys($this->configuration['backofficePassword']); |
||
28 | $this->findById('login-form')->submit(); |
||
29 | $emailElementSearch = WebDriverBy::className('page-wrapper'); |
||
30 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($emailElementSearch); |
||
31 | $this->webDriver->wait()->until($condition); |
||
32 | $this->assertTrue((bool) $condition); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @require loginToBackOffice |
||
37 | * |
||
38 | * @throws \Exception |
||
39 | */ |
||
40 | public function getPaylaterBackOffice() |
||
41 | { |
||
42 | $this->webDriver->get(self::MAGENTO_URL.self::BACKOFFICE_FOLDER); |
||
43 | |||
44 | $elementSearch = WebDriverBy::linkText('STORES'); |
||
45 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch); |
||
46 | $this->webDriver->wait()->until($condition); |
||
47 | $this->findByLinkText('STORES')->click(); |
||
48 | |||
49 | sleep(5); |
||
50 | $elementSearch = WebDriverBy::linkText('Configuration'); |
||
51 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch); |
||
52 | $this->webDriver->wait()->until($condition); |
||
53 | $this->findByLinkText('Configuration')->click(); |
||
54 | |||
55 | //Confirmamos que aparece el menu de tabs |
||
56 | $elementSearch = WebDriverBy::id('system_config_tabs'); |
||
57 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch); |
||
58 | $this->webDriver->wait()->until($condition); |
||
59 | |||
60 | //Buscamos la palabra SALES dentro del div anterior |
||
61 | $menuSearch = WebDriverBy::cssSelector("#system_config_tabs > div > div > strong"); |
||
62 | $menuElements = $this->webDriver->findElements($menuSearch); |
||
63 | foreach ($menuElements as $menuElement) { |
||
64 | if (strpos($menuElement->getText(), 'SALES', 0) !== false || |
||
65 | strpos($menuElement->getText(), 'sales', 0) !== false) { |
||
66 | $menuElement->click(); |
||
67 | $this->assertContains('SALES', $menuElement->getText(), $menuElement->getText()); |
||
68 | break; |
||
69 | } |
||
70 | } |
||
71 | |||
72 | $elementSearch = WebDriverBy::linkText('Payment Methods'); |
||
73 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch); |
||
74 | $this->webDriver->wait()->until($condition); |
||
75 | $this->findByLinkText('Payment Methods')->click(); |
||
76 | |||
77 | $elementSearch = WebDriverBy::id('payment_us_other_payment_methods-head'); |
||
78 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch); |
||
79 | $this->webDriver->wait()->until($condition); |
||
80 | $otherElement = $this->findById('payment_us_other_payment_methods-head'); |
||
81 | if ($otherElement->getAttribute('class')!='open') { |
||
82 | $otherElement->click(); |
||
83 | } |
||
84 | |||
85 | $verify = WebDriverBy::id('payment_us_paylater-head'); |
||
86 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($verify); |
||
87 | $this->webDriver->wait()->until($condition); |
||
88 | $this->assertTrue((bool) $condition, "PR4"); |
||
89 | $paylaterElement = $this->findById('payment_us_paylater-head'); |
||
90 | if ($paylaterElement->getAttribute('class')!='open') { |
||
91 | $paylaterElement->click(); |
||
92 | } |
||
93 | |||
94 | $verify = WebDriverBy::id('payment_us_paylater_active'); |
||
95 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($verify); |
||
96 | $this->webDriver->wait()->until($condition); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | public function createAccount() |
||
103 | { |
||
104 | $this->webDriver->get(self::MAGENTO_URL); |
||
105 | $loginButtonSearch = WebDriverBy::linkText('Create an Account'); |
||
106 | $condition = WebDriverExpectedCondition::elementToBeClickable($loginButtonSearch); |
||
107 | $this->webDriver->wait()->until($condition); |
||
108 | $this->findByLinkText('Create an Account')->click(); |
||
109 | |||
110 | $random = rand(0, 1000); |
||
111 | $this->findById('firstname')->clear()->sendKeys($this->configuration['firstname']); |
||
112 | $this->findById('lastname')->sendKeys($this->configuration['lastname']); |
||
113 | $this->findById('email_address')->sendKeys($this->configuration['email']); |
||
114 | $this->findById('password')->sendKeys($this->configuration['password']); |
||
115 | $this->findById('password-confirmation')->sendKeys($this->configuration['password']); |
||
116 | $this->findById('form-validate')->submit(); |
||
117 | |||
118 | $addressButton = WebDriverBy::partialLinkText('Address Book'); |
||
119 | $condition = WebDriverExpectedCondition::elementToBeClickable($addressButton); |
||
120 | $this->webDriver->wait()->until($condition); |
||
121 | |||
122 | $this->assertContains( |
||
123 | $this->configuration['firstname'], |
||
124 | $this->findByClass('block-dashboard-info')->getText() |
||
125 | ); |
||
126 | $this->findByPartialLinkText('Address Book')->click(); |
||
127 | |||
128 | $addressLink = WebDriverBy::id('firstname'); |
||
129 | $condition = WebDriverExpectedCondition::presenceOfElementLocated($addressLink); |
||
130 | $this->webDriver->wait()->until($condition); |
||
131 | |||
132 | $this->webDriver->findElement(WebDriverBy::id('country')) |
||
133 | ->findElement(WebDriverBy::cssSelector("option[value='ES']")) |
||
134 | ->click(); |
||
135 | |||
136 | $this->findById('telephone')->clear()->sendKeys($this->configuration['phone']); |
||
137 | $this->findById('street_1')->sendKeys($this->configuration['street']); |
||
138 | $this->findById('city')->sendKeys($this->configuration['city']); |
||
139 | $this->findById('zip')->sendKeys($this->configuration['zip']); |
||
140 | |||
141 | $regionLink = WebDriverBy::id('region_id'); |
||
142 | $condition = WebDriverExpectedCondition::presenceOfElementLocated($regionLink); |
||
143 | $this->webDriver->wait()->until($condition); |
||
144 | |||
145 | $this->webDriver->findElement(WebDriverBy::id('region_id')) |
||
146 | ->findElement(WebDriverBy::cssSelector("option[value='161']")) |
||
147 | ->click(); |
||
148 | $this->findById('form-validate')->submit(); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @require createAccount |
||
153 | * |
||
154 | * @throws \Exception |
||
155 | */ |
||
156 | public function loginToFrontend() |
||
157 | { |
||
158 | $this->webDriver->get(self::MAGENTO_URL); |
||
159 | $loginButton = WebDriverBy::partialLinkText('Sign In'); |
||
160 | $condition = WebDriverExpectedCondition::elementToBeClickable($loginButton); |
||
161 | $this->webDriver->wait()->until($condition); |
||
162 | $this->assertTrue((bool) $condition); |
||
163 | $this->webDriver->findElement($loginButton)->click(); |
||
164 | |||
165 | $verifyElement = WebDriverBy::id('login-form'); |
||
166 | $condition = WebDriverExpectedCondition::elementToBeClickable($verifyElement); |
||
167 | $this->webDriver->wait()->until($condition); |
||
168 | $this->assertTrue((bool) $condition); |
||
169 | |||
170 | $this->findById('email')->sendKeys($this->configuration['email']); |
||
171 | $this->findById('pass')->sendKeys($this->configuration['password']); |
||
172 | $this->findById('login-form')->submit(); |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * |
||
177 | * @throws \Exception |
||
178 | */ |
||
179 | public function logoutFromFrontend() |
||
180 | { |
||
181 | $this->webDriver->get(self::MAGENTO_URL.self::LOGOUT_FOLDER); |
||
182 | |||
183 | $validatorSearch = WebDriverBy::className('base'); |
||
184 | $actualString = $this->webDriver->findElement($validatorSearch)->getText(); |
||
185 | $compareString = (strpos($actualString, "You are signed out")) === false ? false : true; |
||
186 | $this->assertTrue($compareString, "PR1-PR4"); |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * Configure product |
||
191 | */ |
||
192 | public function checkProductPage() |
||
193 | { |
||
194 | $this->checkSimulator(); |
||
195 | $pmtSimElement = WebDriverBy::className('PmtSimulator'); |
||
196 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($pmtSimElement); |
||
197 | $this->webDriver->wait()->until($condition); |
||
198 | sleep(2); |
||
199 | $simulatorElement = $this->findByClass('PmtSimulator'); |
||
200 | $currentSimulatorPrice = $simulatorElement->getAttribute('data-pmt-amount'); |
||
201 | $this->configureProduct(self::PRODUCT_QTY_AFTER); |
||
202 | sleep(10); |
||
203 | $simulatorElement = $this->findByClass('PmtSimulator'); |
||
204 | $newPrice = $simulatorElement->getAttribute('data-pmt-amount'); |
||
205 | $this->assertNotEmpty($currentSimulatorPrice, $currentSimulatorPrice); |
||
206 | $this->assertNotNull($currentSimulatorPrice, $currentSimulatorPrice); |
||
207 | $newSimulatorPrice = $currentSimulatorPrice * self::PRODUCT_QTY_AFTER; |
||
208 | $this->assertEquals($newPrice, $newSimulatorPrice, "PR22,PR23"); |
||
209 | |||
210 | $paymentFormElement = WebDriverBy::id('product-addtocart-button'); |
||
211 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($paymentFormElement); |
||
212 | $this->webDriver->wait()->until($condition); |
||
213 | $addToCartButton = $this->findById('product-addtocart-button'); |
||
214 | $addToCartButton->click(); |
||
215 | sleep(5); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @param bool $verifySimulator |
||
220 | * |
||
221 | * @throws \Exception |
||
222 | */ |
||
223 | public function goToProduct($verifySimulator = true) |
||
224 | { |
||
225 | $this->webDriver->get(self::MAGENTO_URL); |
||
226 | $this->findByLinkText(self::PRODUCT_NAME)->click(); |
||
227 | $condition = WebDriverExpectedCondition::titleContains(self::PRODUCT_NAME); |
||
228 | $this->webDriver->wait()->until($condition); |
||
229 | $this->assertTrue((bool) $condition); |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * @require goToProduct |
||
234 | * |
||
235 | * @throws \Exception |
||
236 | */ |
||
237 | public function addProduct() |
||
238 | { |
||
239 | $addToCartSearch = WebDriverBy::id('product-addtocart-button'); |
||
240 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($addToCartSearch); |
||
241 | $this->webDriver->wait()->until($condition); |
||
242 | $this->assertTrue((bool) $condition); |
||
243 | $this->webDriver->findElement($addToCartSearch)->click(); |
||
244 | |||
245 | $validatorSearch = WebDriverBy::className('messages'); |
||
246 | $actualString = $this->webDriver->findElement($validatorSearch)->getText(); |
||
247 | $addedMessage = "You added ".self::PRODUCT_NAME." to your shopping cart"; |
||
248 | $compareString = (strpos($actualString, $addedMessage)) === false ? false : true; |
||
249 | $this->assertTrue($compareString); |
||
250 | |||
251 | //You added Fusion Backpack to your shopping cart. |
||
252 | $shoppingCartSearch = WebDriverBy::id('shopping_cart'); |
||
253 | $this->webDriver->findElement($shoppingCartSearch)->click(); |
||
254 | $shoppingCartTitle = WebDriverBy::id('cart_title'); |
||
255 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($shoppingCartTitle); |
||
256 | $this->webDriver->wait()->until($condition); |
||
257 | $this->assertTrue((bool) $condition); |
||
258 | } |
||
259 | |||
260 | public function goToCart() |
||
261 | { |
||
262 | $this->webDriver->get(self::MAGENTO_URL.self::CART_FOLDER); |
||
263 | $this->findByLinkText(self::PRODUCT_NAME)->click(); |
||
264 | $condition = WebDriverExpectedCondition::titleContains(self::CART_TITLE); |
||
265 | $this->webDriver->wait()->until($condition); |
||
266 | $this->assertTrue((bool) $condition); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * Config product quantity |
||
271 | * |
||
272 | * @param $qty |
||
273 | */ |
||
274 | public function configureProduct($qty = 1) |
||
275 | { |
||
276 | $qtyElements = $this->webDriver->findElements(WebDriverBy::id('qty')); |
||
277 | foreach ($qtyElements as $qtyElement) { |
||
278 | $qtyElement->clear()->sendKeys($qty); |
||
279 | } |
||
280 | } |
||
281 | |||
282 | /** |
||
283 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
284 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
285 | */ |
||
286 | public function goToCheckout() |
||
287 | { |
||
288 | $this->webDriver->get(self::MAGENTO_URL.self::CHECKOUT_FOLDER); |
||
289 | $condition = WebDriverExpectedCondition::titleContains(self::CHECKOUT_TITLE); |
||
290 | $this->webDriver->wait()->until($condition); |
||
291 | $this->assertTrue((bool)$condition, self::MAGENTO_URL.self::CHECKOUT_FOLDER); |
||
292 | } |
||
293 | |||
294 | /** |
||
295 | * @throws \Exception |
||
296 | */ |
||
297 | public function verifyUTF8() |
||
298 | { |
||
299 | $paymentFormElement = WebDriverBy::className('FieldsPreview-desc'); |
||
300 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($paymentFormElement); |
||
301 | $this->webDriver->wait()->until($condition); |
||
302 | $this->assertTrue((bool) $condition); |
||
303 | $this->assertSame( |
||
304 | $this->configuration['firstname'] . ' ' . $this->configuration['lastname'], |
||
305 | $this->findByClass('FieldsPreview-desc')->getText() |
||
306 | ); |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * Verify Paylater |
||
311 | * |
||
312 | * @throws \Exception |
||
313 | */ |
||
314 | public function verifyPaylater() |
||
315 | { |
||
316 | $condition = WebDriverExpectedCondition::titleContains(self::PMT_TITLE); |
||
317 | $this->webDriver->wait(300)->until($condition, $this->webDriver->getCurrentURL()); |
||
318 | $this->assertTrue((bool)$condition, "PR32"); |
||
319 | |||
320 | SeleniumHelper::finishForm($this->webDriver); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * Prepare checkout, called from BuyRegistered and BuyUnregistered |
||
325 | */ |
||
326 | public function prepareCheckout() |
||
327 | { |
||
328 | $firstnameElement = WebDriverBy::name('firstname'); |
||
329 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($firstnameElement); |
||
330 | $this->webDriver->wait(200)->until($condition); |
||
331 | $this->assertTrue((bool) $condition); |
||
332 | |||
333 | sleep(5); |
||
334 | $countryElement = WebDriverBy::name('country_id'); |
||
335 | $condition = WebDriverExpectedCondition::elementToBeClickable($countryElement); |
||
336 | $this->webDriver->wait()->until($condition); |
||
337 | $this->assertTrue((bool) $condition); |
||
338 | $this->webDriver->findElement(WebDriverBy::name('country_id')) |
||
339 | ->findElement(WebDriverBy::cssSelector("option[value='ES']")) |
||
340 | ->click(); |
||
341 | |||
342 | $this->findByName('postcode')->clear()->sendKeys($this->configuration['zip']); |
||
343 | $this->findByName('street[0]')->clear()->sendKeys($this->configuration['street']); |
||
344 | $this->findByName('city')->clear()->sendKeys($this->configuration['city']); |
||
345 | $this->findById('customer-email')->clear()->sendKeys($this->configuration['email']); |
||
346 | $this->findByName('firstname')->clear()->sendKeys($this->configuration['firstname']); |
||
347 | $this->findByName('lastname')->clear()->sendKeys($this->configuration['lastname']); |
||
348 | $this->findByName('telephone')->clear()->sendKeys($this->configuration['phone']); |
||
349 | |||
350 | $this->webDriver->findElement(WebDriverBy::name('region_id')) |
||
351 | ->findElement(WebDriverBy::cssSelector("option[value='139']")) |
||
352 | ->click(); |
||
353 | |||
354 | $this->goToPayment(); |
||
355 | } |
||
356 | |||
357 | /** |
||
358 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
359 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
360 | */ |
||
361 | public function goToPayment() |
||
362 | { |
||
363 | $shippingElement = WebDriverBy::xpath("//input[@value='flatrate_flatrate']"); |
||
364 | $condition = WebDriverExpectedCondition::elementToBeClickable($shippingElement); |
||
365 | $this->webDriver->wait()->until($condition); |
||
366 | $this->assertTrue((bool) $condition); |
||
367 | |||
368 | sleep(5); |
||
369 | $shippingButton = $this->webDriver->findElement($shippingElement); |
||
370 | if (!$shippingButton->isSelected()) { |
||
371 | $shippingButton->click(); |
||
372 | } |
||
373 | |||
374 | sleep(5); |
||
375 | $continueElement = WebDriverBy::className('continue'); |
||
376 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($continueElement); |
||
377 | $this->webDriver->wait()->until($condition); |
||
378 | $this->assertTrue((bool) $condition); |
||
379 | |||
380 | $condition = WebDriverExpectedCondition::elementToBeClickable($continueElement); |
||
381 | $this->webDriver->wait()->until($condition); |
||
382 | $this->assertTrue((bool) $condition); |
||
383 | |||
384 | $this->findByClass('continue')->click(); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
389 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
390 | */ |
||
391 | public function preparePaymentMethod() |
||
392 | { |
||
393 | $paylaterElement = WebDriverBy::id('paylater'); |
||
394 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($paylaterElement); |
||
395 | $this->webDriver->wait()->until($condition); |
||
396 | $this->assertTrue((bool) $condition); |
||
397 | |||
398 | $condition = WebDriverExpectedCondition::elementToBeClickable($paylaterElement); |
||
399 | $this->webDriver->wait()->until($condition); |
||
400 | $this->assertTrue((bool) $condition); |
||
401 | |||
402 | sleep(10); |
||
403 | $this->findById('paylater')->click(); |
||
404 | |||
405 | sleep(2); |
||
406 | |||
407 | $paylaterElement = WebDriverBy::className('payment-group'); |
||
408 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($paylaterElement); |
||
409 | $this->webDriver->wait()->until($condition); |
||
410 | $this->assertTrue((bool) $condition); |
||
411 | |||
412 | $menuSearch = WebDriverBy::cssSelector("#checkout-payment-method-load > .payment-methods > .payment-group > ._active > .payment-method-title"); |
||
413 | $menuElement = $this->webDriver->findElement($menuSearch); |
||
414 | $actualString = $menuElement->getText(); |
||
415 | $compareString = (strstr($actualString, $this->configuration['methodName'])) === false ? false : true; |
||
416 | $this->assertTrue($compareString, $actualString, "PR25,PR26"); |
||
417 | |||
418 | $descriptionSearch = WebDriverBy::cssSelector("#checkout-payment-method-load > .payment-methods > .payment-group > ._active > .payment-method-content"); |
||
419 | $descriptionElement = $this->webDriver->findElement($descriptionSearch); |
||
420 | $actualString = $descriptionElement->getText(); |
||
421 | $this->assertContains($this->configuration['checkoutDescription'], $actualString, "PR54"); |
||
422 | |||
423 | $this->checkSimulator(); |
||
424 | |||
425 | $priceSearch = WebDriverBy::className('price'); |
||
426 | $priceElements = $this->webDriver->findElements($priceSearch); |
||
427 | $price = $priceElements['6']->getText(); |
||
428 | |||
429 | $this->assertNotEquals($price, 0, $price); |
||
430 | $this->assertNotEmpty($price); |
||
431 | |||
432 | $simulatorElement = $this->findByClass('PmtSimulator'); |
||
433 | $simulatorPrice = $simulatorElement->getAttribute('data-pmt-amount'); |
||
434 | $simulatorPrice = preg_replace('/[^\x{20}-\x{7F}]/u', '', $simulatorPrice); |
||
435 | $price = preg_replace('/[^\x{20}-\x{7F}]/u', '', $price); |
||
436 | $this->assertContains($simulatorPrice, $price, json_encode(array($price,$simulatorPrice))); |
||
437 | |||
438 | sleep(2); |
||
439 | $checkoutButton = WebDriverBy::cssSelector("#checkout-payment-method-load > .payment-methods > .payment-group > ._active > .payment-method-content > .actions-toolbar > .primary"); |
||
440 | $condition = WebDriverExpectedCondition::elementToBeClickable($checkoutButton); |
||
441 | $this->webDriver->wait()->until($condition); |
||
442 | |||
443 | $menuElement = $this->webDriver->findElement($checkoutButton); |
||
444 | $menuElement->click(); |
||
445 | return $price; |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
450 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
451 | */ |
||
452 | public function verifyOrder() |
||
453 | { |
||
454 | $condition = WebDriverExpectedCondition::titleContains(self::SUCCESS_TITLE); |
||
455 | $this->webDriver->wait()->until($condition); |
||
456 | $this->assertTrue((bool) $condition); |
||
457 | |||
458 | $menuSearch = WebDriverBy::className("base"); |
||
459 | $menuElement = $this->webDriver->findElement($menuSearch); |
||
460 | $actualString = $menuElement->getText(); |
||
461 | $this->assertContains('Thank you for your purchase!', $actualString, "PR42"); |
||
462 | } |
||
463 | |||
464 | /** |
||
465 | * @return string |
||
466 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
467 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
468 | */ |
||
469 | public function verifyOrderInformation() |
||
470 | { |
||
471 | $this->findByClass('order-number')->click(); |
||
472 | $condition = WebDriverExpectedCondition::titleContains(self::ORDER_TITLE); |
||
473 | $this->webDriver->wait()->until($condition); |
||
474 | $this->assertTrue((bool) $condition); |
||
475 | |||
476 | $menuSearch = WebDriverBy::cssSelector("div.block-order-details-view > div.block-content > div.box-order-billing-method > div.box-content > dl.payment-method"); |
||
477 | $menuElement = $this->webDriver->findElement($menuSearch); |
||
478 | $actualString = $menuElement->getText(); |
||
479 | $compareString = (strstr($actualString, $this->configuration['methodName'])) === false ? false : true; |
||
480 | $this->assertTrue($compareString, $actualString, "PR49"); |
||
0 ignored issues
–
show
|
|||
481 | |||
482 | $menuSearch = WebDriverBy::cssSelector("#my-orders-table > tfoot > .grand_total > .amount > strong > .price"); |
||
483 | $menuElement = $this->webDriver->findElement($menuSearch); |
||
484 | return $menuElement->getText(); |
||
485 | } |
||
486 | |||
487 | /** |
||
488 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
489 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
490 | */ |
||
491 | public function goToOrder() |
||
492 | { |
||
493 | $condition = WebDriverExpectedCondition::titleContains('Order'); |
||
494 | $this->webDriver->wait()->until($condition); |
||
495 | $this->assertTrue((bool) $condition); |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @throws \Facebook\WebDriver\Exception\NoSuchElementException |
||
500 | * @throws \Facebook\WebDriver\Exception\TimeOutException |
||
501 | */ |
||
502 | private function checkSimulator() |
||
503 | { |
||
504 | $simulatorElementSearch = WebDriverBy::className('PmtSimulator'); |
||
505 | $condition = WebDriverExpectedCondition::visibilityOfElementLocated($simulatorElementSearch); |
||
506 | $this->webDriver->wait()->until($condition); |
||
507 | $this->assertTrue((bool) $condition, "PR19//PR28"); |
||
508 | $simulatorElement = $this->webDriver->findElement(WebDriverBy::className('PmtSimulator')); |
||
509 | $minInstallments = $simulatorElement->getAttribute('data-pmt-num-quota'); |
||
510 | $this->assertEquals($minInstallments, $this->configuration['defaultMinIns'], "PR20//PR29"); |
||
511 | $maxInstallments = $simulatorElement->getAttribute('data-pmt-max-ins'); |
||
512 | $this->assertEquals($maxInstallments, $this->configuration['defaultMaxIns'], "PR20//PR29"); |
||
513 | } |
||
514 | } |
||
515 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.