RegisterTest::fillFormAndSubmit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 24
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 29
rs 9.536
1
<?php
2
3
namespace Test\Register;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Facebook\WebDriver\WebDriverExpectedCondition;
7
use Facebook\WebDriver\WebDriverSelect;
8
9
/**
10
 * Class RegisterTest
11
 * @package Test\Register
12
 *
13
 * @group oscommerce-register
14
 */
15
class RegisterTest extends AbstractRegister
16
{
17
    /**
18
     * Register into OsCommerce
19
     */
20
    public function testRegister()
21
    {
22
        $this->openOsCommerce();
23
        $this->goToAccountPage();
24
        $this->goToAccountCreate();
25
        $this->fillFormAndSubmit();
26
        $this->quit();
27
    }
28
29
    /**
30
     * Fill register form
31
     */
32
    public function fillFormAndSubmit()
33
    {
34
        $this->findByName('gender')->click();
35
        $this->findByName('firstname')->clear()->sendKeys($this->configuration['firstname']);
36
        $this->findByName('lastname')->clear()->sendKeys($this->configuration['lastname']);
37
        $this->findByName('dob')->clear()->sendKeys($this->configuration['birthdate']);
38
        $this->findByName('email_address')->clear()->sendKeys($this->configuration['customeremail']);
39
40
        $this->findByName('street_address')->clear()->sendKeys($this->configuration['address']);
41
        $this->findByName('postcode')->clear()->sendKeys($this->configuration['zip']);
42
        $this->findByName('city')->clear()->sendKeys($this->configuration['city']);
43
        $this->findByName('state')->clear()->sendKeys($this->configuration['city']);
44
        $select = new WebDriverSelect($this->findByName('country'));
45
        $select->selectByValue($this->configuration['country']);
46
        $this->findByName('telephone')->clear()->sendKeys($this->configuration['phone']);
47
        $this->findByName('password')->clear()->sendKeys($this->configuration['customerpwd']);
48
        $this->findByName('confirmation')->clear()->sendKeys($this->configuration['customerpwd']);
49
50
        $myAccountSearch = WebDriverBy::id('tdb4');
51
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($myAccountSearch);
52
        $this->waitUntil($condition);
53
        $myAccountElement = $this->webDriver->findElement($myAccountSearch);
54
        $this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($myAccountElement));
55
        $myAccountElement->click();
56
57
        $okMessage = WebDriverBy::cssSelector('#bodyContent>h1');
58
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($okMessage);
59
        $this->webDriver->wait()->until($condition);
60
        $this->assertSame($this->findByCss('#bodyContent>h1')->getText(), self::SUCCESS_MESSAGE);
61
    }
62
}
63