summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php
blob: 65f137afc462ce11e39a959b9e1489073b16848f (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
<?php

class QuickstartDataList2TestCase extends PradoGenericSelenium2Test
{
	function test()
	{
		$this->url("../../demos/quickstart/index.php?page=Controls.Samples.TDataList.Sample2&amp;notheme=true&amp;lang=en");

		// verify initial presentation
		$this->assertSourceContains("Motherboard");
		$this->assertSourceContains("Monitor");

		// verify selecting an item
		$this->byLinkText("ITN003")->click();
		$this->assertSourceContains("Quantity");
		$this->assertSourceContains("Price");
		$this->assertSourceContains("\$80");
		$this->byLinkText("ITN005")->click();
		$this->assertSourceContains("\$150");

		// verify editting an item
		$this->byId("ctl0_body_DataList_ctl5_ctl0")->click();
		$this->pause(50);
		$this->type("ctl0\$body\$DataList\$ctl5\$ProductQuantity", "11");
		$this->type("ctl0\$body\$DataList\$ctl5\$ProductPrice", "140.99");
		$this->byXPath("//input[@name='ctl0\$body\$DataList\$ctl5\$ProductImported']")->click();
		$this->byLinkText("Save")->click();
		$this->pause(50);

		// verify item is saved
		$this->byLinkText("ITN005")->click();
		$this->assertSourceContains("\$140.99");
		$this->assertSourceContains("11");

		// verify editting another item
		$this->byId("ctl0_body_DataList_ctl3_ctl1")->click();
		$this->pause(50);
		$this->type("ctl0\$body\$DataList\$ctl3\$ProductName", "Hard Drive");
		$this->type("ctl0\$body\$DataList\$ctl3\$ProductQuantity", "23");
		$this->byXPath("//input[@name='ctl0\$body\$DataList\$ctl3\$ProductImported']")->click();
		$this->byLinkText("Cancel")->click();
		$this->pause(50);

		// verify item is canceled
		$this->byLinkText("ITN003")->click();
		$this->assertSourceContains("2");
		$this->assertSourceContains("Harddrive");

		// verify item deletion
		$this->byId("ctl0_body_DataList_ctl3_ctl1")->click();
		$this->pause(50);

		$this->assertEquals("Are you sure?", $this->alertText());
		$this->acceptAlert();

		$this->pause(300); // wait for reload
		$this->byId("ctl0_body_DataList_ctl5_ctl2")->click();
		$this->pause(50);

		$this->assertEquals("Are you sure?", $this->alertText());
		$this->dismissAlert();

		$this->assertSourceContains("Motherboard");
		$this->assertSourceContains("CPU");
		$this->assertSourceNotContains("Harddrive");
		$this->assertSourceContains("Sound card");
		$this->assertSourceContains("Video card");
		$this->assertSourceContains("Keyboard");
		$this->assertSourceContains("Monitor");
	}
}