blob: 5d70b4a8aa1ad1ffc1aa19210d8909a11ecf2abc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
class CatalogProductTest extends OpenCartSeleniumTest {
/**
* @before
*/
protected function setupTest() {
$this->setBrowser('firefox');
$this->setBrowserUrl(HTTP_SERVER);
}
public function testSearch() {
$this->url('index.php?route=common/home');
$this->byCssSelector('input[name="search"]')->click();
$this->keys('Apple');
$this->byCssSelector('i.fa-search')->click();
$this->waitUntil(function() {
if (strpos($this->url(), 'product/search') !== False) {
return true;
}
}, 3000);
$element = $this->byCssSelector('div.caption a');
$this->assertTrue(strpos($element->attribute('href'), 'product_id=42') !== False);
}
public function testAddToCartButton() {
$this->url('index.php?route=product/product&product_id=43');
$this->clickOnElement('button-cart');
$this->url('index.php?route=checkout/cart');
$element = $this->byCssSelector('#accordion + br + .row .table-bordered tr:last-child td:last-child');
$this->assertEquals('$589.50', $element->text());
}
public function testQuantityField() {
$this->url('index.php?route=product/product&product_id=43');
$inputElement = $this->byId('input-quantity');
$inputElement->clear();
$this->clickOnElement('input-quantity');
$this->keys('3');
$this->clickOnElement('button-cart');
$this->url('index.php?route=checkout/cart');
$element = $this->byCssSelector('#accordion + br + .row .table-bordered tr:last-child td:last-child');
$this->assertEquals('$1,768.50', $element->text());
}
public function testWishListButton() {
$this->url('index.php?route=product/product&product_id=43');
$element = $this->byCssSelector('i.fa-heart:last-child');
$element->click();
$this->waitUntil(function() {
if ($this->byCssSelector('.alert-success')) {
return true;
}
}, 2000);
}
public function testCompareButton() {
$this->url('index.php?route=product/product&product_id=43');
$element = $this->byCssSelector('i.fa-exchange');
$element->click();
$this->waitUntil(function() {
if ($this->byCssSelector('.alert-success')) {
return true;
}
}, 2000);
}
}
|