. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package PHPUnit_Selenium * @author Giorgio Sironi * @copyright 2010-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ */ use BadMethodCallException; use PHPUnit\Extensions\Selenium2TestCase; use PHPUnit\Extensions\Selenium2TestCase\Keys; use PHPUnit\Extensions\Selenium2TestCase\SessionCommand\Click; use PHPUnit\Extensions\Selenium2TestCase\WebDriverException; use PHPUnit\Extensions\Selenium2TestCase\Window; use Tests\Selenium2TestCase\BaseTestCase; /** * Tests for Selenium2TestCase. * * @package PHPUnit_Selenium * @author Giorgio Sironi * @copyright 2010-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ */ class Selenium2TestCaseTest extends BaseTestCase { protected function tearDown(): void { Selenium2TestCase::setDefaultWaitUntilTimeout(0); Selenium2TestCase::setDefaultWaitUntilSleepInterval(500); } public function testOpen() { $this->url('html/test_open.html'); $this->assertStringEndsWith('html/test_open.html', $this->url()); } public function testVersionCanBeReadFromTheTestCaseClass() { $this->assertEquals(1, version_compare(Selenium2TestCase::VERSION, "1.2.0")); } public function testCamelCaseUrlsAreSupported() { $this->url('html/CamelCasePage.html'); $this->assertStringEndsWith('html/CamelCasePage.html', $this->url()); $this->assertEquals('CamelCase page', $this->title()); } public function testAbsoluteUrlsAreSupported() { $this->url(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL . 'html/test_open.html'); $this->assertEquals('Test open', $this->title()); } public function testElementSelection() { $this->url('html/test_open.html'); $element = $this->byCssSelector('body'); $this->assertEquals('This is a test of the open command.', $element->text()); $this->url('html/test_click_page1.html'); $link = $this->byId('link'); $this->assertEquals('Click here for next page', $link->text()); } public function testMultipleElementsSelection() { $this->url('html/test_element_selection.html'); $elements = $this->elements($this->using('css selector')->value('div')); $this->assertEquals(4, count($elements)); $this->assertEquals('Other div', $elements[0]->text()); } public function testElementFromResponseValue() { $this->url('html/test_open.html'); $elementArray = $this->execute(array( 'script' => 'return document.body;', 'args' => array(), )); $element = $this->elementFromResponseValue($elementArray); $this->assertEquals('This is a test of the open command.', $element->text()); } public function testSelectOptionsInMultiselect() { $this->url('html/test_multiselect.html'); $this->select($this->byId('theSelect'))->selectOptionByValue("option1"); $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); $this->assertEquals(array('First Option','Second Option'), $selectedOptions); $this->select($this->byId('theSelect'))->selectOptionByLabel("Fourth Option"); $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); $this->assertEquals(array('First Option','Second Option','Fourth Option'), $selectedOptions); } public function testClearMultiselectSelectedOptions() { $this->url('html/test_multiselect.html'); $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); $this->assertEquals(array('Second Option'), $selectedOptions); $this->select($this->byId('theSelect'))->clearSelectedOptions(); $selectedOptions = $this->select($this->byId('theSelect'))->selectedLabels(); $this->assertEquals(array(), $selectedOptions); } public function testTheElementWithFocusCanBeInspected() { $this->url('html/test_select.html'); // Select input and check if active $theInput = $this->byCssSelector('input[name="theInput"]'); $theInput->click(); $this->assertTrue($this->active()->equals($theInput), 'Input not recognized as active.'); // Select select-group and check if active $selectGroup = $this->byCssSelector('#selectWithOptgroup'); $selectGroup->click(); $this->assertTrue($this->active()->equals($selectGroup), 'Select-group not recognized as active.'); // Make sure that input is not recognized as selected $this->assertFalse($this->active()->equals($theInput), 'Input falsely recognized as active.'); } public function testActivePageElementReceivesTheKeyStrokes() { $this->markTestIncomplete('Firefox (geckodriver) does not support this command yet'); $this->timeouts()->implicitWait(10000); $this->url('html/test_send_keys.html'); $this->byId('q')->click(); $this->keys('phpunit '); $this->assertEquals('phpunit', $this->byId('result')->text()); } public function testElementsCanBeSelectedAsChildrenOfAlreadyFoundElements() { $this->url('html/test_element_selection.html'); $parent = $this->byCssSelector('div#parentElement'); $child = $parent->element($this->using('css selector')->value('span')); $this->assertEquals('Child span', $child->text()); $rows = $this->byCssSelector('table')->elements($this->using('css selector')->value('tr')); $this->assertEquals(2, count($rows)); } /** * Test on Session and Element * * @dataProvider getObjectsWithAccessToElement */ public function testShortenedApiForSelectionOfElement($factory) { $this->url('html/test_element_selection.html'); $parent = $factory($this); $element = $parent->byClassName('theDivClass'); $this->assertEquals('The right div', $element->text()); $element = $parent->byCssSelector('div.theDivClass'); $this->assertEquals('The right div', $element->text()); $element = $parent->byId('theDivId'); $this->assertEquals('The right div', $element->text()); $element = $parent->byName('theDivName'); $this->assertEquals('The right div', $element->text()); $element = $parent->byTag('div'); $this->assertEquals('Other div', $element->text()); $element = $parent->byXPath('//div[@id]'); $this->assertEquals('The right div', $element->text()); } public function getObjectsWithAccessToElement() { return array( array(function($s) { return $s; }), array(function($s) { return $s->byXPath('//body'); }) ); } public function testElementsKnowTheirTagName() { $this->url('html/test_element_selection.html'); $element = $this->byClassName('theDivClass'); $this->assertEquals('div', $element->name()); } public function testFormElementsKnowIfTheyAreEnabled() { $this->url('html/test_form_elements.html'); $this->assertTrue($this->byId('enabledInput')->enabled()); $this->assertFalse($this->byId('disabledInput')->enabled()); } public function testElementsKnowTheirAttributes() { $this->url('html/test_element_selection.html'); $element = $this->byId('theDivId'); $this->assertEquals('theDivClass', $element->attribute('class')); } public function testElementsDiscoverTheirEqualityWithOtherElements() { $this->url('html/test_element_selection.html'); $element = $this->byId('theDivId'); $differentElement = $this->byId('parentElement'); $equalElement = $this->byId('theDivId'); $this->assertTrue($element->equals($equalElement)); $this->assertFalse($element->equals($differentElement)); } public function testElementsKnowWhereTheyAreInThePage() { $this->url('html/test_element_selection.html'); $element = $this->byCssSelector('body'); $location = $element->location(); $this->assertEquals(0, $location['x']); $this->assertEquals(0, $location['y']); } public function testElementsKnowTheirSize() { $this->url('html/test_geometry.html'); $element = $this->byId('rectangle'); $size = $element->size(); $this->assertEquals(200, $size['width']); $this->assertEquals(100, $size['height']); } public function testElementsKnowTheirCssPropertiesValues() { $this->url('html/test_geometry.html'); $element = $this->byId('colored'); $this->assertMatchesRegularExpression('/rgb[a]?\(0,\s*0,\s*255[,\s*1]?\)/', $element->css('background-color')); } public function testClick() { $this->timeouts()->implicitWait(10000); $this->url('html/test_click_page1.html'); $link = $this->byId('link'); $link->click(); $back = $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); $back->click(); $this->byId('link'); $this->assertEquals('Click Page 1', $this->title()); $withImage = $this->byId('linkWithEnclosedImage'); $withImage->click(); $back = $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); $back->click(); $enclosedImage = $this->byId('enclosedImage'); $enclosedImage->click(); $back = $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); $back->click(); $toAnchor = $this->byId('linkToAnchorOnThisPage'); $toAnchor->click(); $withOnClick = $this->byId('linkWithOnclickReturnsFalse'); $this->assertEquals('Click Page 1', $this->title()); $withOnClick->click(); $this->assertEquals('Click Page 1', $this->title()); } public function testDoubleclick() { $this->markTestIncomplete('Moveto command is not in the webdriver specification'); $this->url('html/test_doubleclick.html'); $link = $this->byId('link'); $this->moveto($link); $this->doubleclick(); $this->assertEquals('doubleclicked', $this->alertText()); $this->acceptAlert(); } public function testByLinkText() { $this->timeouts()->implicitWait(10000); $this->url('html/test_click_page1.html'); $link = $this->byLinkText('Click here for next page'); $link->click(); $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); } public function testByPartialLinkText() { $this->timeouts()->implicitWait(10000); $this->url('html/test_click_page1.html'); $link = $this->byPartialLinkText('next page'); $link->click(); $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); } public function testClicksOnJavaScriptHref() { $this->url('html/test_click_javascript_page.html'); $this->clickOnElement('link'); $this->assertEquals('link clicked', $this->byId('result')->text()); } public function testTypingViaTheKeyboard() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value('TestUser'); $this->assertEquals('TestUser', $usernameInput->value()); $passwordInput = $this->byName('password'); $passwordInput->value('testUserPassword'); $this->assertEquals('testUserPassword', $passwordInput->value()); $this->clickOnElement('submitButton'); $h2 = $this->byCssSelector('h2'); $this->assertMatchesRegularExpression('/Welcome, TestUser!/', $h2->text()); } /** * #190 */ public function testTypingAddsCharactersToTheCurrentValueOfAnElement() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value('first'); $usernameInput->value('second'); $this->assertEquals('firstsecond', $usernameInput->value()); } /** * #165 */ public function testNumericValuesCanBeTyped() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value(1.13); $this->assertEquals('1.13', $usernameInput->value()); } public function testFormsCanBeSubmitted() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value('TestUser'); $this->byId('submitButton')->submit(); // fix slow submiting $this->waitUntil(function() { try { $this->byCssSelector('h2'); return true; } catch (WebDriverException $e) { return null; } }, 10000); $h2 = $this->byCssSelector('h2'); $this->assertMatchesRegularExpression('/Welcome, TestUser!/', $h2->text()); } /** * @depends testTypingViaTheKeyboard */ public function testTextTypedInAreasCanBeCleared() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value('TestUser'); $usernameInput->clear(); $this->assertEquals('', $usernameInput->value()); } public function testTypingNonLatinText() { $this->url('html/test_type_page1.html'); $usernameInput = $this->byName('username'); $usernameInput->value('テストユーザ'); $this->assertEquals('テストユーザ', $usernameInput->value()); } public function testSelectElements() { $this->url('html/test_select.html'); $option = $this->byId('o2'); $this->assertEquals('Second Option', $option->text()); $this->assertEquals('option2', $option->value()); $this->assertTrue($option->selected()); $option = $this->byId('o3'); $this->assertFalse($option->selected()); $option->click(); $this->assertTrue($option->selected()); } public function testASelectObjectCanBeBuildWithASpecificAPI() { $this->url('html/test_select.html'); $select = $this->select($this->byCssSelector('select')); // basic $this->assertEquals('Second Option', $select->selectedLabel()); $this->assertEquals('option2', $select->selectedValue()); // by text, value attribute or generic criteria $select->selectOptionByLabel('Fourth Option'); $this->assertEquals('option4', $select->selectedValue()); $select->selectOptionByValue('option3'); $this->assertEquals('Third Option', $select->selectedLabel()); $select->selectOptionByCriteria($this->using('id')->value('o4')); $this->assertEquals('option4', $select->selectedValue()); // empty values $select->selectOptionByValue(''); $this->assertEquals('Empty Value Option', $select->selectedLabel()); $select->selectOptionByLabel(''); $this->assertEquals('', $select->selectedLabel()); } /** * Ticket 119 */ public function testSelectOptionSelectsDescendantElement() { $this->url('html/test_select.html'); $select = $this->select($this->byCssSelector('#secondSelect')); $this->assertEquals("option2", $select->selectedValue()); $select->selectOptionByLabel("First Option"); $this->assertEquals("option1", $select->selectedValue()); $select->selectOptionByValue("option2"); $this->assertEquals("option2", $select->selectedValue()); } /** * Ticket 170 */ public function testSelectOptgroupDoNotGetInTheWay() { $this->url('html/test_select.html'); $select = $this->select($this->byCssSelector('#selectWithOptgroup')); $select->selectOptionByLabel("Second"); $this->assertEquals("2", $select->selectedValue()); $select->selectOptionByValue("1"); $this->assertEquals("1", $select->selectedValue()); } public function testCheckboxesCanBeSelectedAndDeselected() { $this->markTestIncomplete("Flaky: fails on clicking in some browsers."); $this->url('html/test_check_uncheck.html'); $beans = $this->byId('option-beans'); $butter = $this->byId('option-butter'); $this->assertTrue($beans->selected()); $this->assertFalse($butter->selected()); $butter->click(); $this->assertTrue($butter->selected()); $butter->click(); $this->assertFalse($butter->selected()); } public function testRadioBoxesCanBeSelected() { $this->url('html/test_check_uncheck.html'); $spud = $this->byId('base-spud'); $rice = $this->byId('base-rice'); $this->assertTrue($spud->selected()); $this->assertFalse($rice->selected()); $rice->click(); $this->assertFalse($spud->selected()); $this->assertTrue($rice->selected()); $spud->click(); $this->assertTrue($spud->selected()); $this->assertFalse($rice->selected()); } public function testWaitPeriodsAreImplicitInSelection() { $this->timeouts()->implicitWait(10000); $this->url('html/test_delayed_element.html'); $element = $this->byId('createElementButton')->click(); $div = $this->byXPath("//div[@id='delayedDiv']"); $this->assertEquals('Delayed div.', $div->text()); } public function testTimeoutsCanBeDefinedForAsynchronousExecutionOfJavaScript() { $this->url('html/test_open.html'); $this->timeouts()->asyncScript(10000); $script = 'var callback = arguments[0]; window.setTimeout(function() { callback(document.title); }, 1000); '; $result = $this->executeAsync(array( 'script' => $script, 'args' => array() )); $this->assertEquals("Test open", $result); } public function testTheBackAndForwardButtonCanBeUsedToNavigate() { $this->url('html/test_click_page1.html'); $this->assertEquals('Click Page 1', $this->title()); $this->clickOnElement('link'); $this->byId('previousPage'); $this->assertEquals('Click Page Target', $this->title()); $this->back(); $this->assertEquals('Click Page 1', $this->title()); $this->forward(); $this->assertEquals('Click Page Target', $this->title()); } public function testThePageCanBeRefreshed() { $this->url('html/test_page.slow.html'); $this->assertStringEndsWith('html/test_page.slow.html', $this->url()); $this->assertEquals('Slow Loading Page', $this->title()); $this->clickOnElement('changeSpan'); $this->assertEquals('Changed the text', $this->byId('theSpan')->text()); $this->refresh(); $this->assertEquals('This is a slow-loading page.', $this->byId('theSpan')->text()); $this->clickOnElement('changeSpan'); $this->assertEquals('Changed the text', $this->byId('theSpan')->text()); } public function testLinkEventsAreGenerated() { $this->markTestIncomplete("Waiting for new phpunit-selenium release"); $this->url('html/test_form_events.html'); $eventLog = $this->byId('eventlog'); $eventLog->clear(); $this->clickOnElement('theLink'); $this->waitUntil(function () { $this->alertIsPresent(); }, 8000); $this->assertEquals('link clicked', $text); $this->acceptAlert(); $this->assertContains('{click(theLink)}', $eventLog->value()); } public function testButtonEventsAreGenerated() { $this->url('html/test_form_events.html'); $eventLog = $this->byId('eventlog'); $eventLog->clear(); $this->clickOnElement('theButton'); // Not generated with firefox //$this->assertContains('{focus(theButton)}', $eventLog->value()); $this->assertStringContainsString('{click(theButton)}', $eventLog->value()); $eventLog->clear(); $this->clickOnElement('theSubmit'); $this->assertStringContainsString('{click(theSubmit)} {submit}', $eventLog->value()); } public function testSelectEventsAreGeneratedbutOnlyIfANewSelectionIsMade() { $this->url('html/test_form_events.html'); $select = $this->select($this->byId('theSelect')); $eventLog = $this->byId('eventlog'); $eventLog->clear(); $select->selectOptionByLabel('First Option'); $this->assertEquals('option1', $select->selectedValue()); $this->assertStringContainsString('{focus(theSelect)}', $eventLog->value()); $this->assertStringContainsString('{change(theSelect)}', $eventLog->value()); $eventLog->clear(); $select->selectOptionByLabel('First Option'); $this->assertEquals('option1', $select->selectedValue()); $this->assertEquals('', $eventLog->value()); } public function testRadioEventsAreGenerated() { $this->markTestIncomplete("Flaky: fails on focus in some browsers."); $this->url('html/test_form_events.html'); $first = $this->byId('theRadio1'); $second = $this->byId('theRadio2'); $eventLog = $this->byId('eventlog'); $this->assertFalse($first->selected()); $this->assertFalse($second->selected()); $this->assertEquals('', $eventLog->value()); $first->click(); $this->assertContains('{focus(theRadio1)}', $eventLog->value()); $this->assertContains('{click(theRadio1)}', $eventLog->value()); $this->assertContains('{change(theRadio1)}', $eventLog->value()); $this->assertNotContains('theRadio2', $eventLog->value()); $eventLog->clear(); $first->click(); $this->assertContains('{focus(theRadio1)}', $eventLog->value()); $this->assertContains('{click(theRadio1)}', $eventLog->value()); } public function testCheckboxEventsAreGenerated() { $this->markTestIncomplete("Flaky: fails on focus in some browsers."); $this->url('html/test_form_events.html'); $checkbox = $this->byId('theCheckbox'); $eventLog = $this->byId('eventlog'); $this->assertFalse($checkbox->selected()); $this->assertEquals('', $eventLog->value()); $checkbox->click(); $this->assertContains('{focus(theCheckbox)}', $eventLog->value()); $this->assertContains('{click(theCheckbox)}', $eventLog->value()); $this->assertContains('{change(theCheckbox)}', $eventLog->value()); $eventLog->clear(); $checkbox->click(); $this->assertContains('{focus(theCheckbox)}', $eventLog->value()); $this->assertContains('{click(theCheckbox)}', $eventLog->value()); $this->assertContains('{change(theCheckbox)}', $eventLog->value()); } public function testTextEventsAreGenerated() { $this->markTestIncomplete('focus event not generated with firefox (geckodriver)'); $this->url('html/test_form_events.html'); $textBox = $this->byId('theTextbox'); $eventLog = $this->byId('eventlog'); $this->assertEquals('', $textBox->value()); $this->assertEquals('', $eventLog->value()); $textBox->value('first value'); $this->assertContains('{focus(theTextbox)}', $eventLog->value()); } public function testMouseEventsAreGenerated() { $this->url('html/test_form_events.html'); $this->clickOnElement('theTextbox'); $this->clickOnElement('theButton'); $eventLog = $this->byId('eventlog'); $this->assertStringContainsString('{mouseover(theTextbox)}', $eventLog->value()); $this->assertStringContainsString('{mousedown(theButton)}', $eventLog->value()); $this->assertStringContainsString('{mouseover(theTextbox)}', $eventLog->value()); $this->assertStringContainsString('{mousedown(theButton)}', $eventLog->value()); } public function testKeyEventsAreGenerated() { $this->url('html/test_form_events.html'); $this->byId('theTextbox')->value('t'); $this->assertStringContainsString('{keydown(theTextbox - 84)}' . ' {keypress(theTextbox - 116)}' . ' {keyup(theTextbox - 84)}', $this->byId('eventlog')->value()); } public function testConfirmationsAreHandledAsAlerts() { $this->markTestIncomplete("Waiting for new phpunit-selenium release"); $this->url('html/test_confirm.html'); $this->clickOnElement('confirmAndLeave'); $text = ""; $this->waitUntil(function () { $this->alertIsPresent(); }, 8000); $this->assertEquals('You are about to go to a dummy page.', $this->alertText()); $this->dismissAlert(); $this->assertEquals('Test Confirm', $this->title()); $this->clickOnElement('confirmAndLeave'); $this->waitUntil(function () { $this->alertIsPresent(); }, 8000); $this->assertEquals('You are about to go to a dummy page.', $this->alertText()); $this->acceptAlert(); $this->assertEquals('This is a dummy page.', $this->byId('theSpan')->text()); } public function testPromptsCanBeAnsweredByTyping() { $this->markTestIncomplete("Waiting for new phpunit-selenium release"); $this->url('html/test_prompt.html'); $this->clickOnElement('promptAndLeave'); $this->waitUntil(function () { $this->alertIsPresent(); }, 8000); $this->assertEquals("Type 'yes' and click OK", $this->alertText()); $this->dismissAlert(); $this->assertEquals('Test Prompt', $this->title()); $this->clickOnElement('promptAndLeave'); $this->waitUntil(function () { $this->alertIsPresent(); }, 8000); $this->alertText('yes'); $this->acceptAlert(); $this->assertEquals('Dummy Page', $this->title()); } public function testInvisibleElementsDoNotHaveADisplayedText() { $this->url('html/test_visibility.html'); $this->assertEquals('A visible paragraph', $this->byId('visibleParagraph')->text()); $this->assertTrue($this->byId('visibleParagraph')->displayed()); $this->assertEquals('', $this->byId('hiddenParagraph')->text()); $this->assertFalse($this->byId('hiddenParagraph')->displayed()); $this->assertEquals('', $this->byId('suppressedParagraph')->text()); $this->assertEquals('', $this->byId('classSuppressedParagraph')->text()); $this->assertEquals('', $this->byId('jsClassSuppressedParagraph')->text()); $this->assertEquals('', $this->byId('hiddenSubElement')->text()); $this->assertEquals('sub-element that is explicitly visible', $this->byId('visibleSubElement')->text()); $this->assertEquals('', $this->byId('suppressedSubElement')->text()); $this->assertEquals('', $this->byId('jsHiddenParagraph')->text()); } public function testScreenshotsCanBeTakenAtAnyMoment() { $this->url('html/test_open.html'); $screenshot = $this->currentScreenshot(); $this->assertTrue(is_string($screenshot)); $this->assertTrue(strlen($screenshot) > 0); $this->markTestIncomplete('By guaranteeing the size of the window, we could add a deterministic assertion for the image.'); } public function testACurrentWindowHandleAlwaysExist() { $this->url('html/test_open.html'); $window = $this->windowHandle(); $this->assertTrue(is_string($window)); $this->assertTrue(strlen($window) > 0); $allHandles = $this->windowHandles(); $this->assertEquals(array('0' => $window), $allHandles); } public function testThePageSourceCanBeRead() { $this->url('html/test_open.html'); $source = $this->source(); // No guarantee that it will exactly match the contents of the file //$this->assertStringStartsWith('