Passed
Pull Request — master (#4)
by Cesar
02:54
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 35
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 41 3
1
<?php
2
3
namespace Pagantis\SeleniumFormUtils\Step;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Pagantis\SeleniumFormUtils\Step\ConfirmData\Missing;
7
8
/**
9
 * Class Application
10
 *
11
 * @package Pagantis\SeleniumFormUtils\Step
12
 */
13
class Application extends AbstractStep
14
{
15
    /**
16
     * Handler step
17
     */
18
    const STEP = '/application';
19
20
    const CARD_NUMBER = '4507670001000009';
21
22
    const CARD_CVC = '989';
23
24
    const CARD_HOLDER = 'John Doe';
25
26
    /**
27
     * Pass from confirm-data to next step in Application Form
28
     *
29
     * @throws \Exception
30
     */
31
    public function run()
32
    {
33
        $this->validateStep(self::STEP);
34
        //Click on confirm:
35
36
        /*
37
         * Optional Full Name:
38
         */
39
        try {
40
            $name = $this->webDriver->findElement(WebDriverBy::name('name'));
41
            $name->clear()->sendKeys($this->faker->name . ' ' . $this->faker->lastName);
0 ignored issues
show
Bug introduced by
The property lastName does not seem to exist on Faker\Factory.
Loading history...
Bug introduced by
The property name does not seem to exist on Faker\Factory.
Loading history...
42
        } catch (\Exception $exception) {
43
            unset($exception);
44
        }
45
46
        try {
47
            $this->moveToIFrame('hosted-field-number');
48
            $this->waitTobeVisible(WebDriverBy::name('credit-card-number'));
49
            $creditCardNumber = $this->webDriver->findElement(WebDriverBy::name('credit-card-number'));
50
            $creditCardNumber->clear()->sendKeys(self::CARD_NUMBER);
51
            $this->moveToParent();
52
            $this->moveToIFrame('hosted-field-name');
53
            $cardHolder = $this->webDriver->findElement(WebDriverBy::name('name'));
54
            $cardHolder->clear()->sendKeys(self::CARD_HOLDER);
55
            $this->moveToParent();
56
            $this->moveToIFrame('hosted-field-cvv');
57
            $cvv = $this->webDriver->findElement(WebDriverBy::name('cvv'));
58
            $cvv->clear()->sendKeys(self::CARD_CVC);
59
            $this->moveToParent();
60
            $this->moveToIFrame('hosted-field-expirationDate');
61
            $expiration = $this->webDriver->findElement(WebDriverBy::name('expiration'));
62
            $expiration->clear()->sendKeys('12'. date('y'));
63
            $this->moveToParent();
64
            $acceptedTerms = $this->webDriver->findElement(WebDriverBy::className('Form-checkboxSkin'));
65
            $acceptedTerms->click();
66
        } catch (\Exception $exception) {
67
            unset($exception);
68
        }
69
70
        $formContinue = $this->webDriver->findElement(WebDriverBy::name('form-continue'));
71
        $formContinue->click();
72
    }
73
}
74