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); |
|
|
|
|
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
|
|
|
|