diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2014-03-25 22:41:33 +0100 |
---|---|---|
committer | David <ottodavid@gmx.net> | 2014-08-21 17:32:09 +0200 |
commit | 94e34ad61868dc6a28de6f1a708d63ae0b6b4cf9 (patch) | |
tree | 79c298bb04c06c2d3673ceec9f8ae81968be5295 /tests | |
parent | 2f2a18b9ccf154543ca02e9c189f23cc2862017d (diff) |
More selenium2 tests porting
(cherry picked from commit 68bbb645ba5be61c2e3024ac3943c7346b30f1f2)
Conflicts:
tests/FunctionalTests/tickets/tests/Ticket587TestCase.php
tests/FunctionalTests/tickets/tests/Ticket719TestCase.php
Diffstat (limited to 'tests')
15 files changed, 57 insertions, 71 deletions
diff --git a/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php b/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php index 6b2f6f97..2b9a0166 100755 --- a/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php +++ b/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php @@ -207,7 +207,7 @@ class ActiveRatingListTestCase extends PradoGenericSelenium2Test $this->assertElementPresent("//input[@id='{$base}RatingList_c4']/../../../td[contains(@class, 'rating')]"); $this->assertElementPresent("//input[@id='{$base}RatingList_c5']/../../../td[contains(@class, 'rating')]"); - $this->mouseOver("//input[@id='{$base}RatingList_c4']/../.."); + $this->moveto($this->byXPath("//input[@id='{$base}RatingList_c4']/../..")); $this->assertText("{$base}Status", "Excellent"); $this->assertElementPresent("//input[@id='{$base}RatingList_c0']/../../../td[contains(@class, 'rating_hover')]"); $this->assertElementPresent("//input[@id='{$base}RatingList_c1']/../../../td[contains(@class, 'rating_hover')]"); @@ -217,7 +217,7 @@ class ActiveRatingListTestCase extends PradoGenericSelenium2Test $this->assertElementPresent("//input[@id='{$base}RatingList_c5']/../../../td[not(contains(@class, 'rating_hover'))]"); $this->assertElementPresent("//input[@id='{$base}RatingList_c5']/../../../td[contains(@class, 'rating')]"); - $this->mouseOut("//input[@id='{$base}RatingList_c4']/../.."); + $this->moveto($this->byCssSelector('body')); $this->assertText("{$base}Status", "CaptionID='Status'"); $this->assertElementPresent("//input[@id='{$base}RatingList_c0']/../../../td[contains(@class, 'rating_selected')]"); $this->assertElementPresent("//input[@id='{$base}RatingList_c1']/../../../td[contains(@class, 'rating_selected')]"); @@ -228,7 +228,7 @@ class ActiveRatingListTestCase extends PradoGenericSelenium2Test $this->assertElementPresent("//input[@id='{$base}RatingList_c5']/../../../td[contains(@class, 'rating')]"); - $this->mouseOver("//input[@id='{$base}RatingList_c1']/../.."); + $this->moveto($this->byXPath("//input[@id='{$base}RatingList_c1']/../..")); $this->assertText("{$base}Status", "Fair"); $this->byXPath("//input[@id='{$base}RatingList_c1']/../..")->click(); diff --git a/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php b/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php index 52095321..3865e33d 100755 --- a/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php @@ -30,15 +30,15 @@ class QuickstartTextBoxTestCase extends PradoGenericSelenium2Test // auto postback textbox, CausesValidation=false $this->assertValue("ctl0\$body\$ctl6", "change me"); - $this->type("ctl0\$body\$ctl6", "change mes"); + $this->typeSpecial("ctl0\$body\$ctl6", "change mes"); $this->assertValue("ctl0\$body\$ctl6", "text changed"); // auto postback textbox, CausesValidation=true $this->assertNotVisible('ctl0_body_ctl7'); - $this->type("ctl0\$body\$TextBox3", "test"); + $this->typeSpecial("ctl0\$body\$TextBox3", "test"); // $this->pause(1000); $this->assertVisible('ctl0_body_ctl7'); - $this->type("ctl0\$body\$TextBox3", "non test"); + $this->typeSpecial("ctl0\$body\$TextBox3", "non test"); $this->assertNotVisible('ctl0_body_ctl7'); // submitting textbox with a button @@ -48,7 +48,7 @@ class QuickstartTextBoxTestCase extends PradoGenericSelenium2Test // SafeText $this->assertText("ctl0_body_Output","test"); - $this->type("ctl0\$body\$TextBox2","<a href=javascript:xxx>malicious code</a>"); + $this->typeSpecial("ctl0\$body\$TextBox2","<a href=javascript:xxx>malicious code</a>"); $this->assertText("ctl0_body_Output","malicious code"); // password @@ -72,7 +72,7 @@ End of message // auto postback textbox $this->assertValue("ctl0\$body\$ctl14", "change me"); - $this->type("ctl0\$body\$ctl14", "change mes"); + $this->typeSpecial("ctl0\$body\$ctl14", "change mes"); $this->assertValue("ctl0\$body\$ctl14", "text changed"); $this->assertValue("ctl0\$body\$ctl10", "This is a\nmultiline\ntextbox."); $this->assertValue("ctl0\$body\$ctl11", "This is a multiline text box. @@ -82,10 +82,10 @@ End of message // textbox associated with a validator $this->assertNotVisible('ctl0_body_ctl15'); - $this->type("ctl0\$body\$MultiTextBox3", "demo"); + $this->typeSpecial("ctl0\$body\$MultiTextBox3", "demo"); // $this->pause(1000); $this->assertVisible('ctl0_body_ctl15'); - $this->type("ctl0\$body\$MultiTextBox3", "non demo"); + $this->typeSpecial("ctl0\$body\$MultiTextBox3", "non demo"); $this->assertNotVisible('ctl0_body_ctl15'); } } diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket290.page b/tests/FunctionalTests/tickets/protected/pages/Ticket290.page index e9d40b92..3d4bf647 100755 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket290.page +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket290.page @@ -1,18 +1,17 @@ <com:TContent ID="Content"> - <h3>Needs manual testing</h3> <com:TPanel ID="panel1" DefaultButton="button2" Style="border:1px solid #ccc; padding:2em"> <com:TTextBox ID="textbox1" /> - + <com:TCustomValidator ControlToValidate="textbox1" OnServerValidate="customValidate" ValidationGroup="group1" ErrorMessage="required" /> - - <com:TButton ID="button1" Text="Button 1" + + <com:TButton ID="button1" Text="Button 1" ValidationGroup="group1" OnClick="button_clicked" /> - <com:TButton ID="button2" Text="Button 2 (default)" + <com:TButton ID="button2" Text="Button 2 (default)" ValidationGroup="group1" OnClick="button_clicked" /> <com:TLabel ID="label1" Text="Label 1" /> diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket586.page b/tests/FunctionalTests/tickets/protected/pages/Ticket586.page index 29751cab..31bc7237 100755 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket586.page +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket586.page @@ -1,5 +1,4 @@ <com:TContent ID="Content">
-<h3>Needs manual testing</h3>
<com:TPanel DefaultButton="button2" Style="border:1px solid #ccc; padding:2em;">
<com:TTextBox ID="text1" />
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket719.page b/tests/FunctionalTests/tickets/protected/pages/Ticket719.page index b36d2d66..3f2bc17b 100755 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket719.page +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket719.page @@ -1,5 +1,4 @@ <com:TContent id="Content"> -<h3>Needs manual testing</h3> <style> .autocomplete { @@ -45,7 +44,7 @@ ul.different OnSuggest="suggestCountries" Separator=", " OnSuggestionSelected="suggestion_selected" ResultPanel.CssClass="autocomplete" CausesValidation="false" /> - + </p> <p> <com:TButton OnClick="validForm" Text="Validate Form" /><br/> diff --git a/tests/FunctionalTests/tickets/protected/pages/ToggleTest.page b/tests/FunctionalTests/tickets/protected/pages/ToggleTest.page index 0d633657..0d633657 100644..100755 --- a/tests/FunctionalTests/tickets/protected/pages/ToggleTest.page +++ b/tests/FunctionalTests/tickets/protected/pages/ToggleTest.page diff --git a/tests/FunctionalTests/tickets/protected/pages/ToggleTest.php b/tests/FunctionalTests/tickets/protected/pages/ToggleTest.php index 31cf0851..31cf0851 100644..100755 --- a/tests/FunctionalTests/tickets/protected/pages/ToggleTest.php +++ b/tests/FunctionalTests/tickets/protected/pages/ToggleTest.php diff --git a/tests/FunctionalTests/tickets/tests/Ticket205TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket205TestCase.php index 57b0c95b..35274e6f 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket205TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket205TestCase.php @@ -7,7 +7,9 @@ class Ticket205TestCase extends PradoGenericSelenium2Test $base = 'ctl0_Content_'; $this->url("tickets/index.php?page=Ticket205"); $this->assertEquals($this->title(), "Verifying Ticket 205"); - $this->assertNotVisible("{$base}validator1"); + + $validator=$this->byId("{$base}validator1"); + $this->assertFalse($validator->displayed()); $this->type("{$base}textbox1", "test"); $this->byId("{$base}button1")->click(); @@ -15,10 +17,13 @@ class Ticket205TestCase extends PradoGenericSelenium2Test $this->assertEquals("error", $this->alertText()); $this->acceptAlert(); - $this->assertVisible("{$base}validator1"); + $this->assertTrue($validator->displayed()); + + // type() calls clear() that triggers a focus change and thus a second alert + $this->typeSpecial("{$base}textbox1", "Prado"); - $this->type("{$base}textbox1", "Prado"); $this->byId("{$base}button1")->click(); - $this->assertNotVisible("{$base}validator1"); + $validator=$this->byId("{$base}validator1"); + $this->assertFalse($validator->displayed()); } } diff --git a/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php index 3adb107c..948d8642 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php @@ -14,7 +14,12 @@ class Ticket578TestCase extends PradoGenericSelenium2Test $this->assertText("{$base}label1", "Button 1 was clicked :"); $text="helloworld"; - $this->runScript("tinyMCE.get('{$base}text1').setContent('{$text}')"); + + $this->execute(array( + 'script' => "tinyMCE.get('{$base}text1').setContent('{$text}')", + 'args' => array() + )); + $this->byId("{$base}button1")->click(); $this->pause(800); $this->assertText("{$base}label1", "Button 1 was clicked : <p>{$text}</p>"); diff --git a/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php index aa81a55e..cb42c343 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php @@ -16,7 +16,6 @@ class Ticket587TestCase extends PradoGenericSelenium2Test $this->assertText($base."label1", "Selection 2: value 3 - item 4"); $this->type($base.'text1', 't'); - $this->runScript("Prado.Registry.get('{$base}text1').onKeyPress({})"); $this->pause(800); $this->select($base."list2", "asd 3 - item 2"); $this->pause(800); diff --git a/tests/FunctionalTests/tickets/tests/Ticket622TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket622TestCase.php index 672a1d18..b51f55d3 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket622TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket622TestCase.php @@ -10,8 +10,9 @@ class Ticket622TestCase extends PradoGenericSelenium2Test $this->byId($base.'ctl0')->click(); $this->pause(800); - $this->assertAttribute($base.'ALB@style',''); - $this->assertAttribute('css=span#acb span@style', ''); - $this->assertAttribute('css=span#arb span@style', ''); + + $this->assertEquals('', $this->byId($base.'ALB')->attribute('style')); + $this->assertEquals('', $this->byCssSelector('span#acb span')->attribute('style')); + $this->assertEquals('', $this->byCssSelector('span#arb span')->attribute('style')); } } diff --git a/tests/FunctionalTests/tickets/tests/Ticket719TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket719TestCase.php index cc460ee7..46346ca1 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket719TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket719TestCase.php @@ -14,18 +14,17 @@ class Ticket719TestCase extends PradoGenericSelenium2Test $this->assertVisible("${base}ctl0", 'Required'); $this->assertVisible("${base}ctl1", 'Required'); - $this->type("${base}autocomplete", 'f'); - $this->runScript("Prado.Registry.get('${base}autocomplete').onKeyPress({})"); + $this->byId("${base}autocomplete")->click(); + + $this->keys('f'); $this->pause(500); $this->assertContains('Finland', $this->source()); - $this->type("${base}autocomplete", 'fr'); - $this->runScript("Prado.Registry.get('${base}autocomplete').onKeyPress({})"); + $this->keys('r'); $this->pause(500); $this->assertContains('French', $this->source()); - $this->type("${base}autocomplete", 'fra'); - $this->runScript("Prado.Registry.get('${base}autocomplete').onKeyPress({})"); + $this->keys('a'); $this->pause(500); $this->assertContains('France', $this->source()); @@ -33,7 +32,11 @@ class Ticket719TestCase extends PradoGenericSelenium2Test $this->pause(800); $this->assertNotVisible("${base}ctl1"); - $this->type("${base}textbox", "Prado"); + $this->byId("${base}textbox")->clear(); + $this->byId("${base}textbox")->value('Prado'); + // trigger onblur() event + $this->byCssSelector('body')->click(); + $this->assertNotVisible("${base}ctl0"); $this->byId("${base}ctl2")->click(); diff --git a/tests/FunctionalTests/tickets/tests/Ticket823TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket823TestCase.php index 7b7a7759..163eb541 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket823TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket823TestCase.php @@ -6,7 +6,7 @@ class Ticket823TestCase extends PradoGenericSelenium2Test { $this->url('tickets/index.php?page=Ticket823'); $this->assertEquals($this->title(), "Verifying Ticket 823"); $base = 'ctl0_Content_'; - $this->assertElementPresent('xpath=//option[@value="Choose..."]'); + $this->assertElementPresent('//option[@value="Choose..."]'); } } diff --git a/tests/FunctionalTests/tickets/tests/Ticket876TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket876TestCase.php index 29d4d6c6..361235fc 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket876TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket876TestCase.php @@ -7,9 +7,9 @@ class Ticket876TestCase extends PradoGenericSelenium2Test { $this->assertEquals($this->title(), "Verifying Ticket 876"); $base = 'ctl0_Content_'; - $this->assertElementPresent('xpath=//link[@rel="stylesheet"]'); + $this->assertElementPresent('//link[@rel="stylesheet"]'); $this->byId($base.'Button')->click(); - $this->assertElementNotPresent('xpath=//link[@rel="stylesheet"]'); + $this->assertElementNotPresent('//link[@rel="stylesheet"]'); /*$this->select($base.'Date_month', 10); $this->select($base.'Date_day', 22); diff --git a/tests/test_tools/PradoGenericSelenium2Test.php b/tests/test_tools/PradoGenericSelenium2Test.php index c81f6e9a..23dfeb61 100644..100755 --- a/tests/test_tools/PradoGenericSelenium2Test.php +++ b/tests/test_tools/PradoGenericSelenium2Test.php @@ -64,15 +64,8 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase protected function getElement($id) { - if(strpos($id, 'xpath=')===0) - { - return $this->byXPath(substr($id, 6)); - } elseif(strpos($id, 'css=')===0) { - return $this->byCssSelector(substr($id, 4)); - } elseif(strpos($id, 'id=')===0) { + if(strpos($id, 'id=')===0) { return $this->byId(substr($id, 3)); - } elseif(strpos($id, 'link=')===0) { - return $this->byLinkText(substr($id, 5)); } elseif(strpos($id, 'name=')===0) { return $this->byName(substr($id, 5)); } elseif(strpos($id, '//')===0) { @@ -123,6 +116,15 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase protected function type($id, $txt='') { $element = $this->getElement($id); + $element->clear(); + $element->value($txt); + // trigger onblur() event + $this->byCssSelector('body')->click(); + } + + protected function typeSpecial($id, $txt='') + { + $element = $this->getElement($id); // clear the textbox without using clear() that triggers onchange() // the idea is to focus the input, move to the end of the text and hit // backspace until the input is empty. @@ -148,24 +150,6 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase $this->byCssSelector('body')->click(); } - protected function mouseOver($id) - { - $this->moveto(array( - 'element' => $this->getElement($id), -// 'xoffset' => 1, -// 'yoffset' => 1, - )); - } - - protected function mouseOut($id) - { - $this->moveto(array( - 'element' => $this->getElement('css=body'), -// 'xoffset' => 0, -// 'yoffset' => 0, - )); - } - protected function select($id, $value) { $select = parent::select($this->getElement($id)); @@ -227,14 +211,6 @@ class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase $this->assertSame($index, parent::select($this->getElement($id))->selectedValue()); } - protected function runScript($script) - { - $this->execute(array( - 'script' => $script, - 'args' => array() - )); - } - protected function assertAlertNotPresent() { try { |