├── .ci ├── after_script.sh ├── before_script.sh ├── common_env.sh ├── phpunit-environment.conf ├── setup.sh ├── start.sh ├── travis_env.sh ├── vagrant_env.sh └── vagrant_pre_setup.sh ├── .gitignore ├── .travis.yml ├── ChangeLog.markdown ├── LICENSE ├── PHPUnit └── Extensions │ ├── Selenium2TestCase.php │ ├── Selenium2TestCase │ ├── Command.php │ ├── CommandsHolder.php │ ├── Driver.php │ ├── Element.php │ ├── Element │ │ ├── Accessor.php │ │ └── Select.php │ ├── ElementCommand │ │ ├── Attribute.php │ │ ├── Click.php │ │ ├── Css.php │ │ ├── Equals.php │ │ ├── GenericAccessor.php │ │ ├── GenericPost.php │ │ ├── Rect.php │ │ └── Value.php │ ├── ElementCriteria.php │ ├── Exception.php │ ├── Keys.php │ ├── KeysHolder.php │ ├── NoSeleniumException.php │ ├── Response.php │ ├── ScreenshotListener.php │ ├── Session.php │ ├── Session │ │ ├── Cookie.php │ │ ├── Cookie │ │ │ └── Builder.php │ │ ├── Storage.php │ │ └── Timeouts.php │ ├── SessionCommand │ │ ├── AcceptAlert.php │ │ ├── Active.php │ │ ├── AlertText.php │ │ ├── Click.php │ │ ├── DismissAlert.php │ │ ├── File.php │ │ ├── Frame.php │ │ ├── GenericAccessor.php │ │ ├── GenericAttribute.php │ │ ├── Keys.php │ │ ├── Location.php │ │ ├── Log.php │ │ ├── MoveTo.php │ │ ├── Orientation.php │ │ ├── Url.php │ │ └── Window.php │ ├── SessionStrategy.php │ ├── SessionStrategy │ │ ├── Isolated.php │ │ └── Shared.php │ ├── StateCommand.php │ ├── URL.php │ ├── WaitUntil.php │ ├── WebDriverException.php │ └── Window.php │ ├── SeleniumBrowserSuite.php │ ├── SeleniumCommon │ ├── Autoload.php │ ├── Autoload.php.in │ ├── ExitHandler.php │ ├── RemoteCoverage.php │ ├── append.php │ ├── phpunit_coverage.php │ └── prepend.php │ └── SeleniumTestSuite.php ├── README.md ├── Tests ├── CodeCoverageTest.php ├── Selenium2TestCase │ ├── BaseTestCase.php │ ├── Coverage │ │ ├── CookieTest.php │ │ ├── DummyClass.php │ │ ├── RemoteCoverageTest.php │ │ ├── SingleFileTest.php │ │ ├── singleFile.php │ │ └── singleFileCoverage.php │ ├── CustomDesiredCapabilitiesTest.php │ ├── FailuresTest.php │ ├── LogTest.php │ ├── MobileFeaturesTest.php │ ├── MultipleBrowsersMethodTest.php │ ├── MultipleBrowsersPropertyTest.php │ ├── PageObjectTest.php │ ├── RegressionsTest.php │ ├── ScreenshotListenerTest.php │ ├── SessionCommand │ │ └── FileTest.php │ ├── SessionInSetupTest.php │ ├── SetUpPageTest.php │ ├── SuiteBuildingTest.php │ ├── TimeoutTest.php │ ├── URLTest.php │ ├── WaitUntilTest.php │ └── fixtures │ │ └── SuiteBuildingSuites.php └── Selenium2TestCaseTest.php ├── Vagrantfile ├── build.xml ├── build ├── PHPCS │ ├── Sniffs │ │ └── Whitespace │ │ │ └── ConcatenationSpacingSniff.php │ └── ruleset.xml └── phpmd.xml ├── composer.json ├── phpunit-selenium-bootstrap.php ├── phpunit.xml.dist └── selenium-1-tests ├── coverage ├── dummy.html └── dummy.txt ├── html ├── CamelCasePage.html ├── banner.gif ├── test_check_uncheck.html ├── test_click_javascript_page.html ├── test_click_page1.html ├── test_click_page2.html ├── test_confirm.html ├── test_count.html ├── test_delayed_element.html ├── test_doubleclick.html ├── test_dummy_page.html ├── test_editable.html ├── test_element_rect.html ├── test_element_selection.html ├── test_focus_on_blur.html ├── test_form_elements.html ├── test_form_events.html ├── test_frames.html ├── test_geometry.html ├── test_locators.html ├── test_log.html ├── test_mouse_buttons.html ├── test_moveto.html ├── test_multiselect.html ├── test_open.html ├── test_page.slow.html ├── test_prompt.html ├── test_reload_onchange_page.html ├── test_select.html ├── test_select_window.html ├── test_select_window_popup.html ├── test_send_keys.html ├── test_slowloading_page.html ├── test_special_keys.html ├── test_store_value.html ├── test_submit.html ├── test_text_patterns.html ├── test_type_page1.html ├── test_type_page2.html ├── test_verifications.html ├── test_verify_alert.html ├── test_visibility.html └── test_wait.html ├── php └── file_upload.php └── selenese └── test_selenese_directory.html /.ci/after_script.sh: -------------------------------------------------------------------------------- 1 | killall php 2 | killall python 3 | killall java 4 | -------------------------------------------------------------------------------- /.ci/before_script.sh: -------------------------------------------------------------------------------- 1 | BEFORE_SCRIPT_DIR=$(dirname $0) 2 | 3 | source $BEFORE_SCRIPT_DIR/common_env.sh 4 | source $BEFORE_SCRIPT_DIR/travis_env.sh 5 | 6 | source $BEFORE_SCRIPT_DIR/setup.sh 7 | 8 | source $BEFORE_SCRIPT_DIR/start.sh 9 | -------------------------------------------------------------------------------- /.ci/common_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SELENIUM_HUB_URL='http://127.0.0.1:4444' 4 | SELENIUM_JAR=/usr/share/selenium/selenium-server-standalone.jar 5 | SELENIUM_DOWNLOAD_URL=https://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar 6 | GECKODRIVER_DOWNLOAD_URL=https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz 7 | GECKODRIVER_TAR=/tmp/geckodriver.tar.gz 8 | PHP_VERSION=$(php -v) 9 | -------------------------------------------------------------------------------- /.ci/phpunit-environment.conf: -------------------------------------------------------------------------------- 1 | [program:selenium] 2 | command=xvfb-run -e /dev/stdout java -Dwebdriver.firefox.bin=/usr/bin/firefox -jar /usr/share/selenium/selenium-server-standalone.jar 3 | autostart=false ; selenium 4 | 5 | [program:python-webserver] 6 | command=python -m SimpleHTTPServer 8080 7 | directory=. ; python-webserver 8 | autostart=false ; python-webserver 9 | -------------------------------------------------------------------------------- /.ci/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get update 4 | 5 | if [ ! -x "$(command -v composer)" ]; then 6 | echo "Installing Composer" 7 | php -r "readfile('https://getcomposer.org/installer');" | sudo php -d apc.enable_cli=0 -- --install-dir=/usr/local/bin --filename=composer 8 | else 9 | echo "Updating Composer" 10 | sudo composer self-update 11 | fi 12 | 13 | echo "Installing dependencies" 14 | composer install 15 | 16 | echo "Installing supervisord" 17 | sudo apt-get install supervisor -y --no-install-recommends 18 | sudo cp ./.ci/phpunit-environment.conf /etc/supervisor/conf.d/ 19 | sudo sed -i "s/^directory=.*webserver$/directory=${ESCAPED_BUILD_DIR}\\/selenium-1-tests/" /etc/supervisor/conf.d/phpunit-environment.conf 20 | sudo sed -i "s/^autostart=.*selenium$/autostart=true/" /etc/supervisor/conf.d/phpunit-environment.conf 21 | sudo sed -i "s/^autostart=.*python-webserver$/autostart=true/" /etc/supervisor/conf.d/phpunit-environment.conf 22 | 23 | echo "Installing Firefox" 24 | sudo apt-get install firefox -y --no-install-recommends 25 | 26 | echo "Installing Java 8" 27 | sudo apt-add-repository ppa:openjdk-r/ppa -y 28 | sudo apt-get update 29 | sudo apt-get install openjdk-8-jre-headless -y --no-install-recommends 30 | sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 31 | 32 | if [ ! -f "$SELENIUM_JAR" ]; then 33 | echo "Downloading Selenium" 34 | sudo mkdir -p $(dirname "$SELENIUM_JAR") 35 | sudo wget -nv -O "$SELENIUM_JAR" "$SELENIUM_DOWNLOAD_URL" 36 | fi 37 | 38 | if [ ! -f "/usr/local/bin/geckodriver" ]; then 39 | echo "Downloading geckodriver" 40 | sudo wget -nv -O "$GECKODRIVER_TAR" "$GECKODRIVER_DOWNLOAD_URL" 41 | sudo tar -xvf "$GECKODRIVER_TAR" -C "/usr/local/bin/" 42 | fi 43 | -------------------------------------------------------------------------------- /.ci/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo killall supervisord 4 | sudo killall -9 java 5 | sudo killall -9 Xvfb 6 | sudo rm -f /tmp/.X99-lock 7 | sudo /etc/init.d/supervisor start 8 | 9 | wget --retry-connrefused --tries=120 --waitretry=3 --output-file=/dev/null "$SELENIUM_HUB_URL/wd/hub/status" -O /dev/null 10 | if [ ! $? -eq 0 ]; then 11 | echo "Selenium Server not started" 12 | else 13 | echo "Finished setup" 14 | fi 15 | -------------------------------------------------------------------------------- /.ci/travis_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ESCAPED_BUILD_DIR=$(echo "$TRAVIS_BUILD_DIR" | sed 's/\//\\\//g') 4 | -------------------------------------------------------------------------------- /.ci/vagrant_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ESCAPED_BUILD_DIR="\/vagrant" 4 | -------------------------------------------------------------------------------- /.ci/vagrant_pre_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apt-add-repository ppa:ondrej/php -y 4 | 5 | apt-get update 6 | 7 | apt-get install software-properties-common -y 8 | apt-get install python-software-properties -y 9 | 10 | # installing xvfb, java and php 11 | apt-get install xvfb php7.3-cli php7.3-curl php7.3-xml php7.3-mbstring php-xdebug ncurses-term unzip xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic vim -y --no-install-recommends 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/api 2 | build/code-browser 3 | build/coverage 4 | build/logs 5 | build/pdepend 6 | phpunit.xml 7 | vendor/* 8 | composer.phar 9 | composer.lock 10 | selenium-server-*.jar 11 | Tests/Selenium2TestCase/Coverage/*.dummyTestId 12 | firefox.tar.bz2 13 | firefox/ 14 | *.php~ 15 | /.project 16 | /.buildpath 17 | /.settings 18 | /.vagrant/ 19 | /.idea 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | dist: xenial 3 | php: 4 | - 7.3 5 | - 7.4 6 | 7 | matrix: 8 | allow_failures: 9 | - php: hhvm 10 | 11 | before_script: ./.ci/before_script.sh 12 | script: "vendor/bin/phpunit Tests" 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | PHPUnit_Selenium 2 | 3 | Copyright (c) 2002-2013, Sebastian Bergmann . 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | * Neither the name of Sebastian Bergmann nor the names of his 19 | contributors may be used to endorse or promote products derived 20 | from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/Command.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | use InvalidArgumentException; 48 | 49 | /** 50 | * Base class for implementing commands with special semantics. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | */ 60 | abstract class Command 61 | { 62 | protected $jsonParameters; 63 | private $commandName; 64 | 65 | /** 66 | * @param array $jsonParameters null in case of no parameters 67 | */ 68 | public function __construct($jsonParameters, URL $url) 69 | { 70 | if (!is_array($jsonParameters) && $jsonParameters !== NULL) { 71 | throw new InvalidArgumentException("The JSON parameters must be an array, or a NULL value in case they are not required."); 72 | } 73 | $this->jsonParameters = $jsonParameters; 74 | $this->url = $url; 75 | } 76 | 77 | public function url() 78 | { 79 | return $this->url; 80 | } 81 | 82 | /** 83 | * @return string 84 | */ 85 | abstract public function httpMethod(); 86 | 87 | /** 88 | * @param array $jsonParameters null in case of no parameters 89 | */ 90 | public function jsonParameters() 91 | { 92 | return $this->jsonParameters; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Attribute.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL; 49 | 50 | /** 51 | * Retrieves an attribute of a DOM element. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.4 60 | */ 61 | class Attribute extends Command 62 | { 63 | /** 64 | * @param array $parameter 65 | */ 66 | public function __construct($parameter, URL $attributeResourceBaseUrl) 67 | { 68 | $this->jsonParameters = array(); 69 | $this->url = $attributeResourceBaseUrl->descend($parameter); 70 | } 71 | 72 | public function httpMethod() 73 | { 74 | return 'GET'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Click.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Clicks ok on an alert popup. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | */ 60 | class Click extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | return 'POST'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Css.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL; 49 | 50 | /** 51 | * Retrieves the value of a CSS property. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.4 60 | */ 61 | class Css extends Command 62 | { 63 | /** 64 | * @param array $propertyName 65 | */ 66 | public function __construct($propertyName, URL $cssResourceBaseUrl) 67 | { 68 | $this->jsonParameters = array(); 69 | $this->url = $cssResourceBaseUrl->descend($propertyName); 70 | } 71 | 72 | public function httpMethod() 73 | { 74 | return 'GET'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Equals.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use InvalidArgumentException; 48 | use PHPUnit\Extensions\Selenium2TestCase\Command; 49 | use PHPUnit\Extensions\Selenium2TestCase\Element; 50 | use PHPUnit\Extensions\Selenium2TestCase\URL; 51 | 52 | /** 53 | * Checks equality (same element on the page) with another DOM element. 54 | * 55 | * @package PHPUnit_Selenium 56 | * @author Giorgio Sironi 57 | * @copyright 2010-2013 Sebastian Bergmann 58 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 59 | * @version Release: @package_version@ 60 | * @link http://www.phpunit.de/ 61 | * @since Class available since Release 1.2.4 62 | */ 63 | class Equals extends Command 64 | { 65 | /** 66 | * @param array $parameter 67 | */ 68 | public function __construct($parameter, URL $equalsResourceBaseUrl) 69 | { 70 | $this->jsonParameters = array(); 71 | if (!($parameter instanceof Element)) { 72 | throw new InvalidArgumentException("Elements can only test equality with other Element instances."); 73 | } 74 | $this->url = $equalsResourceBaseUrl->descend($parameter->getId()); 75 | } 76 | 77 | public function httpMethod() 78 | { 79 | return 'GET'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/GenericAccessor.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Class for implementing commands that just return a value 51 | * (obtained with GET). 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.0 60 | */ 61 | class GenericAccessor extends Command 62 | { 63 | public function httpMethod() 64 | { 65 | return 'GET'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/GenericPost.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2012 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Class for implementing commands that just accomplishes an action (via POST). 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2012 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.4 59 | */ 60 | class GenericPost extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | return 'POST'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Rect.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL; 49 | 50 | /** 51 | * Retrieves the element's coordinates 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.4 60 | */ 61 | class Rect extends Command 62 | { 63 | /** 64 | * @param array $parameter 65 | */ 66 | public function __construct($parameter, URL $attributeResourceBaseUrl) 67 | { 68 | $this->jsonParameters = array(); 69 | $this->url = $attributeResourceBaseUrl->descend($parameter); 70 | } 71 | 72 | public function httpMethod() 73 | { 74 | return 'GET'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCommand/Value.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\ElementCommand; 46 | 47 | use BadMethodCallException; 48 | use PHPUnit\Extensions\Selenium2TestCase\SessionCommand\Keys; 49 | 50 | /** 51 | * Get and set the element's value attribute. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.0 60 | */ 61 | class Value extends Keys 62 | { 63 | public function httpMethod() 64 | { 65 | if ($this->jsonParameters) { 66 | return 'POST'; 67 | } 68 | throw new BadMethodCallException("JSON Wire Protocol only supports POST to /value now. To get the value of an element GET /attribute/:naem should be used and this object should never be involved."); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/ElementCriteria.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | use ArrayObject; 48 | 49 | /** 50 | * Conditions for selecting a DOM element. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element 60 | */ 61 | class ElementCriteria extends ArrayObject 62 | { 63 | public function __construct($strategy) 64 | { 65 | $this['using'] = $strategy; 66 | } 67 | 68 | /** 69 | * @return ElementCriteria 70 | */ 71 | public function value($searchTarget) 72 | { 73 | $this['value'] = $searchTarget; 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/Exception.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.6 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | use RuntimeException; 48 | 49 | /** 50 | * Indicates an exception during the execution of Selenium 2 commands. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.6 59 | */ 60 | class Exception extends RuntimeException 61 | { 62 | } 63 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/NoSeleniumException.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.9 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | /** 48 | * @package PHPUnit_Selenium 49 | * @author Giorgio Sironi 50 | * @copyright 2010-2013 Sebastian Bergmann 51 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 52 | * @version Release: @package_version@ 53 | * @link http://www.phpunit.de/ 54 | * @since Class available since Release 1.2.8 55 | */ 56 | class NoSeleniumException extends \PHPUnit\Extensions\Selenium2TestCase\Exception 57 | { 58 | } 59 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/Response.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | /** 48 | * Object representing an HTTP response from the Selenium Server. 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Giorgio Sironi 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since Class available since Release 1.2.0 57 | */ 58 | class Response 59 | { 60 | /** 61 | * @var array decoded response 62 | */ 63 | private $jsonResponse; 64 | 65 | /** 66 | * @var array CURL info for the response. 67 | */ 68 | private $info; 69 | 70 | public function __construct($jsonResponse, $info) 71 | { 72 | $this->jsonResponse = $jsonResponse; 73 | $this->info = $info; 74 | } 75 | 76 | public function getValue() 77 | { 78 | if (isset($this->jsonResponse['value'])) { 79 | return $this->jsonResponse['value']; 80 | } 81 | } 82 | 83 | /** 84 | * @return URL 85 | */ 86 | public function getURL() 87 | { 88 | $url = $this->info['url']; 89 | $sessionId = $this->jsonResponse['sessionId']; 90 | 91 | // if url doesn't have sessionId included - append it manually 92 | // this change was performed in selenium v2.34 93 | // @see https://code.google.com/p/selenium/issues/detail?id=6089 94 | // @see https://github.com/sebastianbergmann/phpunit-selenium/issues/265 95 | if (strpos($url, $sessionId) === FALSE) { 96 | $url .= '/' . $sessionId; 97 | } 98 | 99 | return new URL($url); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/Session/Storage.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.6 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\Session; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Driver; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL; 49 | 50 | /** 51 | * Manage the local storage HTML 5 database. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.6 60 | */ 61 | class Storage 62 | { 63 | private $driver; 64 | private $url; 65 | 66 | public function __construct(Driver $driver, URL $url) 67 | { 68 | $this->driver = $driver; 69 | $this->url = $url; 70 | } 71 | 72 | public function __set($name, $value) 73 | { 74 | $this->driver->curl('POST', $this->url, array( 75 | 'key' => $name, 76 | 'value' => (string)$value 77 | )); 78 | } 79 | 80 | public function __get($name) 81 | { 82 | return $this->driver->curl( 83 | 'GET', 84 | $this->url->descend('key')->descend($name) 85 | )->getValue(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/AcceptAlert.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Clicks Ok on an alert popup. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | */ 60 | class AcceptAlert extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | return 'POST'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Active.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL; 49 | 50 | /** 51 | * Gets the active element from the session 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Marcel Erz 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 60 | */ 61 | class Active extends Command 62 | { 63 | 64 | public function __construct($jsonParameters, URL $url) 65 | { 66 | $url = $url->addCommand('element')->addCommand('active'); 67 | parent::__construct($jsonParameters, $url); 68 | } 69 | 70 | public function httpMethod() 71 | { 72 | return 'POST'; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/AlertText.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use BadMethodCallException; 48 | use PHPUnit\Extensions\Selenium2TestCase\Command; 49 | use PHPUnit\Extensions\Selenium2TestCase\URL; 50 | 51 | /** 52 | * Obtains the text of an alert, or types into a prompt. 53 | * 54 | * @package PHPUnit_Selenium 55 | * @author Giorgio Sironi 56 | * @copyright 2010-2013 Sebastian Bergmann 57 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 58 | * @version Release: @package_version@ 59 | * @link http://www.phpunit.de/ 60 | * @since Class available since Release 1.2.4 61 | */ 62 | class AlertText extends Command 63 | { 64 | public function __construct($argument, URL $url) 65 | { 66 | if (is_string($argument)) { 67 | $jsonParameters =array('text' => $argument); 68 | } else if ($argument == NULL) { 69 | $jsonParameters = NULL; 70 | } else { 71 | throw new BadMethodCallException('Wrong parameters for alertText().'); 72 | } 73 | parent::__construct($jsonParameters, $url); 74 | } 75 | 76 | public function httpMethod() 77 | { 78 | if ($this->jsonParameters) { 79 | return 'POST'; 80 | } 81 | return 'GET'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Click.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.13 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use BadMethodCallException; 48 | use PHPUnit\Extensions\Selenium2TestCase\Command; 49 | use PHPUnit\Extensions\Selenium2TestCase\URL; 50 | 51 | /** 52 | * Sends session click command for emulating LEFT, MIDDLE or RIGHT mouse buttons 53 | * 54 | * @package PHPUnit_Selenium 55 | * @author Ivan Kurnosov 56 | * @copyright 2010-2013 Sebastian Bergmann 57 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 58 | * @version Release: @package_version@ 59 | * @link http://www.phpunit.de/ 60 | * @since Class available since Release 1.2.13 61 | */ 62 | class Click extends Command 63 | { 64 | const LEFT = 0; 65 | const MIDDLE = 1; 66 | const RIGHT = 2; 67 | 68 | public function __construct($argument, URL $url) 69 | { 70 | if (is_null($argument)) { 71 | $jsonParameters = NULL; 72 | } elseif (!is_scalar($argument) || !in_array($argument, array( 73 | self::LEFT, self::RIGHT, self::MIDDLE 74 | ))) { 75 | throw new BadMethodCallException('Wrong parameter for click(): expecting 0, 1 or 2.'); 76 | } else { 77 | $jsonParameters = array('button' => $argument); 78 | } 79 | 80 | parent::__construct($jsonParameters, $url); 81 | } 82 | 83 | public function httpMethod() 84 | { 85 | return 'POST'; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/DismissAlert.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Clicks Cancel on an alert popup. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | */ 60 | class DismissAlert extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | return 'POST'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Frame.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\Element; 49 | 50 | /** 51 | * Changes the focus to a frame. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.4 60 | */ 61 | class Frame extends Command 62 | { 63 | public function __construct($id, $commandUrl) 64 | { 65 | $jsonParameters = array( 66 | 'id' => $this->extractId($id) 67 | ); 68 | 69 | parent::__construct($jsonParameters, $commandUrl); 70 | } 71 | 72 | /** 73 | * @param $id 74 | * @return array 75 | */ 76 | private function extractId($id) 77 | { 78 | if ($this->isElement($id)) { //selenium-element 79 | return $id->toWebDriverObject(); 80 | } 81 | 82 | //html-id or null 83 | return $id; 84 | } 85 | 86 | /** 87 | * @param $id 88 | * @return bool 89 | */ 90 | private function isElement($id) 91 | { 92 | return $id instanceof Element; 93 | } 94 | 95 | public function httpMethod() 96 | { 97 | return 'POST'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/GenericAccessor.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Gets an attribute from the session (title, alert text, etc.) 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.0 59 | */ 60 | class GenericAccessor extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | return 'GET'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/GenericAttribute.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Jonathan Lipps 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Gets or posts an attribute from/to the session (title, alert text, etc.) 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Jonathan Lipps 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.9 59 | */ 60 | class GenericAttribute extends Command 61 | { 62 | public function httpMethod() 63 | { 64 | if ($this->jsonParameters) { 65 | return 'POST'; 66 | } 67 | return 'GET'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Keys.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Christian Soronellas 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use InvalidArgumentException; 48 | use PHPUnit\Extensions\Selenium2TestCase\Command; 49 | use PHPUnit\Extensions\Selenium2TestCase\URL; 50 | 51 | /** 52 | * Gets or sets the current URL of the window. 53 | * 54 | * @package PHPUnit_Selenium 55 | * @author Christian Soronellas 56 | * @copyright 2010-2013 Sebastian Bergmann 57 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 58 | * @version Release: @package_version@ 59 | * @link http://www.phpunit.de/ 60 | * @since Class available since Release 1.2.0 61 | */ 62 | class Keys extends Command 63 | { 64 | public function __construct($jsonParameters, URL $url) 65 | { 66 | if ($jsonParameters === NULL) { 67 | parent::__construct(NULL, $url); 68 | } else { 69 | $jsonParameters = $this->keysForText($jsonParameters); 70 | parent::__construct($jsonParameters, $url); 71 | } 72 | } 73 | 74 | /** 75 | * @return string 76 | */ 77 | public function httpMethod() 78 | { 79 | return 'POST'; 80 | } 81 | 82 | /** 83 | * Given a string returns an array of the characters that compose the string 84 | * 85 | * @param string $text 86 | * @throws InvalidArgumentException 87 | * @return array 88 | */ 89 | public function keysForText($text) 90 | { 91 | if (is_scalar($text)) { 92 | return array('value' => preg_split('//u', (string) $text, -1, PREG_SPLIT_NO_EMPTY)); 93 | } 94 | if (is_array($text)) { 95 | return $text; 96 | } 97 | throw new InvalidArgumentException('The "text" argument should be a string or an array of special characters!'); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Location.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Jonathan Lipps 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | /** 48 | * Gets or posts an attribute from/to the session (title, alert text, etc.) 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Jonathan Lipps 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since Class available since Release 1.2.9 57 | */ 58 | class Location extends GenericAttribute 59 | { 60 | 61 | public function __construct($location, $commandUrl) 62 | { 63 | if ($location !== NULL) { 64 | $jsonParameters = array('location' => $location); 65 | } else { 66 | $jsonParameters = NULL; 67 | } 68 | parent::__construct($jsonParameters, $commandUrl); 69 | } 70 | 71 | public function httpMethod() 72 | { 73 | if ($this->jsonParameters) { 74 | return 'POST'; 75 | } 76 | return 'GET'; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Log.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Andrew Krasichkov 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.3.2 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Get the log for a given log type. Log buffer is reset after each request. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Andrew Krasichkov 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.3.2 59 | */ 60 | class Log extends Command 61 | { 62 | public function __construct($type, $commandUrl) 63 | { 64 | $jsonParameters = array('type' => $type); 65 | parent::__construct($jsonParameters, $commandUrl); 66 | } 67 | 68 | public function httpMethod() 69 | { 70 | return 'POST'; 71 | } 72 | } -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Orientation.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Jonathan Lipps 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | /** 48 | * Gets or posts an attribute from/to the session (title, alert text, etc.) 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Jonathan Lipps 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since Class available since Release 1.2.9 57 | */ 58 | class Orientation extends GenericAttribute 59 | { 60 | 61 | public function __construct($orientation, $commandUrl) 62 | { 63 | if ($orientation !== NULL) { 64 | $jsonParameters = array('orientation' => $orientation); 65 | } else { 66 | $jsonParameters = NULL; 67 | } 68 | parent::__construct($jsonParameters, $commandUrl); 69 | } 70 | 71 | public function httpMethod() 72 | { 73 | if ($this->jsonParameters) { 74 | return 'POST'; 75 | } 76 | return 'GET'; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Url.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.0 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | use PHPUnit\Extensions\Selenium2TestCase\URL as SeleniumURL; 49 | 50 | /** 51 | * Gets or sets the current URL of the window. 52 | * 53 | * @package PHPUnit_Selenium 54 | * @author Giorgio Sironi 55 | * @copyright 2010-2013 Sebastian Bergmann 56 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 57 | * @version Release: @package_version@ 58 | * @link http://www.phpunit.de/ 59 | * @since Class available since Release 1.2.0 60 | */ 61 | class Url extends Command 62 | { 63 | public function __construct($url, $commandUrl, SeleniumURL $baseUrl) 64 | { 65 | if ($url !== NULL) { 66 | $absoluteLocation = $baseUrl->jump($url)->getValue(); 67 | $jsonParameters = array('url' => $absoluteLocation); 68 | } else { 69 | $jsonParameters = NULL; 70 | } 71 | parent::__construct($jsonParameters, $commandUrl); 72 | } 73 | 74 | public function httpMethod() 75 | { 76 | if ($this->jsonParameters) { 77 | return 'POST'; 78 | } 79 | return 'GET'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionCommand/Window.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.4 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionCommand; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Command; 48 | 49 | /** 50 | * Changes the focus to a window. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.4 59 | */ 60 | class Window extends Command 61 | { 62 | public function __construct($name, $commandUrl) 63 | { 64 | $jsonParameters = array('name' => $name); 65 | parent::__construct($jsonParameters, $commandUrl); 66 | } 67 | 68 | public function httpMethod() 69 | { 70 | return 'POST'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionStrategy.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.6 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | /** 48 | * Specifies how to create Session objects for running tests. 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Giorgio Sironi 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since Class available since Release 1.2.6 57 | */ 58 | interface SessionStrategy 59 | { 60 | /** 61 | * @param array $parameters 'host' => Selenium Server machine 62 | 'port' => Selenium Server port 63 | 'secure' => Selenium Server secure flag 64 | 'browser' => a browser name 65 | * 'browserUrl' => base URL to use during the test 66 | */ 67 | public function session(array $parameters); 68 | 69 | public function notSuccessfulTest(); 70 | 71 | public function endOfTest(Session $session = NULL); 72 | } 73 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Isolated.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.6 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase\SessionStrategy; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\Driver; 48 | use PHPUnit\Extensions\Selenium2TestCase\Session; 49 | use PHPUnit\Extensions\Selenium2TestCase\SessionStrategy; 50 | use PHPUnit\Extensions\Selenium2TestCase\URL; 51 | 52 | /** 53 | * Produces a new Session object shared for each test. 54 | * 55 | * @package PHPUnit_Selenium 56 | * @author Giorgio Sironi 57 | * @copyright 2010-2013 Sebastian Bergmann 58 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 59 | * @version Release: @package_version@ 60 | * @link http://www.phpunit.de/ 61 | * @since Class available since Release 1.2.6 62 | */ 63 | class Isolated implements SessionStrategy 64 | { 65 | public function session(array $parameters) 66 | { 67 | $seleniumServerUrl = URL::fromHostAndPort($parameters['host'], $parameters['port'], $parameters['secure']); 68 | $driver = new Driver($seleniumServerUrl, $parameters['seleniumServerRequestsTimeout']); 69 | $capabilities = array_merge($parameters['desiredCapabilities'], 70 | array( 71 | 'browserName' => $parameters['browserName'] 72 | )); 73 | $session = $driver->startSession($capabilities, $parameters['browserUrl']); 74 | return $session; 75 | } 76 | 77 | public function notSuccessfulTest() 78 | { 79 | } 80 | 81 | public function endOfTest(Session $session = NULL) 82 | { 83 | if ($session !== NULL) { 84 | $session->stop(); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/StateCommand.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.5 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | /** 48 | * Gets or sets an attribute of an object. 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Giorgio Sironi 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since Class available since Release 1.2.5 57 | */ 58 | class StateCommand extends Command 59 | { 60 | public function httpMethod() 61 | { 62 | if ($this->jsonParameters) { 63 | return 'POST'; 64 | } 65 | return 'GET'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/WebDriverException.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Christian Becker 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | /** 48 | * Indicates an exception as a result of a non-sucessful WebDriver response status code. 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Christian Becker 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @version Release: @package_version@ 55 | * @link http://www.phpunit.de/ 56 | * @since 57 | */ 58 | class WebDriverException extends \PHPUnit\Extensions\Selenium2TestCase\Exception 59 | { 60 | /* @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes */ 61 | const Success = 0; 62 | const NoSuchDriver = 6; 63 | const NoSuchElement = 7; 64 | const NoSuchFrame = 8; 65 | const UnknownCommand = 9; 66 | const StaleElementReference = 10; 67 | const ElementNotVisible = 11; 68 | const InvalidElementState = 12; 69 | const UnknownError = 13; 70 | const ElementIsNotSelectable = 15; 71 | const JavaScriptError = 17; 72 | const XPathLookupError = 19; 73 | const Timeout = 21; 74 | const NoSuchWindow = 23; 75 | const InvalidCookieDomain = 24; 76 | const UnableToSetCookie = 25; 77 | const UnexpectedAlertOpen = 26; 78 | const NoAlertOpenError = 27; 79 | const ScriptTimeout = 28; 80 | const InvalidElementCoordinates = 29; 81 | const IMENotAvailable = 30; 82 | const IMEEngineActivationFailed = 31; 83 | const InvalidSelector = 32; 84 | const SessionNotCreatedException = 33; 85 | const MoveTargetOutOfBounds = 34; 86 | } -------------------------------------------------------------------------------- /PHPUnit/Extensions/Selenium2TestCase/Window.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Giorgio Sironi 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.2.5 43 | */ 44 | 45 | namespace PHPUnit\Extensions\Selenium2TestCase; 46 | 47 | use PHPUnit\Extensions\Selenium2TestCase\ElementCommand\GenericPost; 48 | 49 | /** 50 | * Object representing a browser window. 51 | * 52 | * @package PHPUnit_Selenium 53 | * @author Giorgio Sironi 54 | * @copyright 2010-2013 Sebastian Bergmann 55 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 56 | * @version Release: @package_version@ 57 | * @link http://www.phpunit.de/ 58 | * @since Class available since Release 1.2.5 59 | * @method array size(array $size = null) Window size as array('width' => $x, 'height' => $y) 60 | * @method array position(array $position = null) Window position as array('x' => $x, 'y' => $y) 61 | * @method array maximize() Maximize window 62 | */ 63 | class Window extends CommandsHolder 64 | { 65 | /** 66 | * @return array class names 67 | */ 68 | protected function initCommands() 69 | { 70 | return array( 71 | 'size' => StateCommand::class, 72 | 'position' => StateCommand::class, 73 | 'maximize' => GenericPost::class, 74 | ); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/Autoload.php.in: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Sebastian Bergmann 39 | * @copyright 2002-2010 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.1.0 43 | */ 44 | 45 | require_once 'File/Iterator/Autoload.php'; 46 | 47 | spl_autoload_register( 48 | function ($class) { 49 | static $classes = NULL; 50 | static $path = NULL; 51 | 52 | if ($classes === NULL) { 53 | $classes = array( 54 | ___CLASSLIST___ 55 | ); 56 | 57 | $path = dirname(dirname(dirname(__FILE__))); 58 | } 59 | 60 | $cn = strtolower($class); 61 | 62 | if (isset($classes[$cn])) { 63 | require $path . $classes[$cn]; 64 | } 65 | } 66 | ); 67 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/ExitHandler.php: -------------------------------------------------------------------------------- 1 | 10 | * 11 | */ 12 | class ExitHandler 13 | { 14 | /** 15 | * Register handler. 16 | * If project have own shutdown hanldler user have to add function to handler 17 | * 18 | */ 19 | public static function init() 20 | { 21 | register_shutdown_function(array(ExitHandler::class, 'handle')); 22 | } 23 | 24 | /** 25 | * Manual include apendable files 26 | */ 27 | public static function handle() 28 | { 29 | $execFile = ini_get('auto_append_file'); 30 | if ($execFile!=='') { 31 | include_once ($execFile); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/RemoteCoverage.php: -------------------------------------------------------------------------------- 1 | coverageScriptUrl = $coverageScriptUrl; 12 | $this->testId = $testId; 13 | } 14 | 15 | public function get() 16 | { 17 | if (!empty($this->coverageScriptUrl)) { 18 | $url = sprintf( 19 | '%s?PHPUNIT_SELENIUM_TEST_ID=%s', 20 | $this->coverageScriptUrl, 21 | urlencode($this->testId) 22 | ); 23 | 24 | $buffer = @file_get_contents($url); 25 | 26 | if ($buffer !== FALSE) { 27 | $coverageData = unserialize($buffer); 28 | if (is_array($coverageData)) { 29 | return $this->matchLocalAndRemotePaths($coverageData); 30 | } else { 31 | throw new Exception('Empty or invalid code coverage data received from url "' . $url . '" (' . var_export($buffer, true) . ')'); 32 | } 33 | } 34 | } 35 | 36 | return array(); 37 | } 38 | 39 | /** 40 | * @param array $coverage 41 | * @return array 42 | * @author Mattis Stordalen Flister 43 | */ 44 | protected function matchLocalAndRemotePaths(array $coverage) 45 | { 46 | $coverageWithLocalPaths = array(); 47 | 48 | foreach ($coverage as $originalRemotePath => $data) { 49 | $remotePath = $originalRemotePath; 50 | $separator = $this->findDirectorySeparator($remotePath); 51 | 52 | while (!($localpath = stream_resolve_include_path($remotePath)) && 53 | strpos($remotePath, $separator) !== FALSE) { 54 | $remotePath = substr($remotePath, strpos($remotePath, $separator) + 1); 55 | } 56 | 57 | if ($localpath && md5_file($localpath) == $data['md5']) { 58 | $coverageWithLocalPaths[$localpath] = $data['coverage']; 59 | } 60 | } 61 | 62 | return $coverageWithLocalPaths; 63 | } 64 | 65 | /** 66 | * @param string $path 67 | * @return string 68 | * @author Mattis Stordalen Flister 69 | */ 70 | protected function findDirectorySeparator($path) 71 | { 72 | if (strpos($path, '/') !== FALSE) { 73 | return '/'; 74 | } 75 | 76 | return '\\'; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/append.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Sebastian Bergmann 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.0.0 43 | */ 44 | 45 | if ( isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && 46 | !isset($_GET['PHPUNIT_SELENIUM_TEST_ID']) && 47 | extension_loaded('xdebug')) { 48 | $GLOBALS['PHPUNIT_FILTERED_FILES'][] = __FILE__; 49 | 50 | $data = xdebug_get_code_coverage(); 51 | xdebug_stop_code_coverage(); 52 | 53 | foreach ($GLOBALS['PHPUNIT_FILTERED_FILES'] as $file) { 54 | unset($data[$file]); 55 | } 56 | 57 | if (is_string($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']) && 58 | is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) { 59 | $file = $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] . 60 | DIRECTORY_SEPARATOR . md5($_SERVER['SCRIPT_FILENAME']); 61 | } else { 62 | $file = $_SERVER['SCRIPT_FILENAME']; 63 | } 64 | 65 | $sanitizedCookieName = str_replace(array('\\'), '_', $_COOKIE['PHPUNIT_SELENIUM_TEST_ID']); 66 | $fullPath = $file . '.' . md5(uniqid(rand(), TRUE)) . '.' . $sanitizedCookieName; 67 | 68 | file_put_contents($fullPath, serialize($data)); 69 | } 70 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/phpunit_coverage.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Sebastian Bergmann 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.0.0 43 | */ 44 | 45 | $directory = realpath(__DIR__); 46 | while ($directory != '/') { 47 | $autoloadCandidate = $directory . '/vendor/autoload.php'; 48 | if (file_exists($autoloadCandidate)) { 49 | require_once $autoloadCandidate; 50 | break; 51 | } 52 | $directory = realpath($directory . '/..'); 53 | } 54 | 55 | // Set this to the directory that contains the code coverage files. 56 | // It defaults to getcwd(). If you have configured a different directory 57 | // in prepend.php, you need to configure the same directory here. 58 | $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = getcwd(); 59 | 60 | if (isset($_GET['PHPUNIT_SELENIUM_TEST_ID'])) { 61 | $facade = new \SebastianBergmann\FileIterator\Facade(); 62 | $sanitizedCookieName = str_replace(array('\\'), '_', $_GET['PHPUNIT_SELENIUM_TEST_ID']); 63 | $files = $facade->getFilesAsArray( 64 | $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 65 | $sanitizedCookieName 66 | ); 67 | 68 | $coverage = array(); 69 | 70 | foreach ($files as $file) { 71 | $data = unserialize(file_get_contents($file)); 72 | unlink($file); 73 | unset($file); 74 | $filter = new \SebastianBergmann\CodeCoverage\Filter(); 75 | 76 | foreach ($data as $file => $lines) { 77 | if ($filter->isFile($file)) { 78 | if (!isset($coverage[$file])) { 79 | $coverage[$file] = array( 80 | 'md5' => md5_file($file), 'coverage' => $lines 81 | ); 82 | } else { 83 | foreach ($lines as $line => $flag) { 84 | if (!isset($coverage[$file]['coverage'][$line]) || 85 | $flag > $coverage[$file]['coverage'][$line]) { 86 | $coverage[$file]['coverage'][$line] = $flag; 87 | } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | 94 | print serialize($coverage); 95 | } 96 | -------------------------------------------------------------------------------- /PHPUnit/Extensions/SeleniumCommon/prepend.php: -------------------------------------------------------------------------------- 1 | . 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Sebastian Bergmann nor the names of his 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * @package PHPUnit_Selenium 38 | * @author Sebastian Bergmann 39 | * @copyright 2010-2013 Sebastian Bergmann 40 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 41 | * @link http://www.phpunit.de/ 42 | * @since File available since Release 1.0.0 43 | */ 44 | 45 | use PHPUnit\Extensions\SeleniumCommon\ExitHandler; 46 | 47 | // By default the code coverage files are written to the same directory 48 | // that contains the covered sourcecode files. Use this setting to change 49 | // the default behaviour and set a specific directory to write the files to. 50 | // If you change the default setting, please make sure to also configure 51 | // the same directory in phpunit_coverage.php. Also note that the webserver 52 | // needs write access to the directory. 53 | 54 | if (!isset($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) { 55 | $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = FALSE; 56 | } 57 | 58 | if ( isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && 59 | !isset($_GET['PHPUNIT_SELENIUM_TEST_ID']) && 60 | extension_loaded('xdebug')) { 61 | $GLOBALS['PHPUNIT_FILTERED_FILES'] = array(__FILE__); 62 | 63 | xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); 64 | } 65 | 66 | include ('ExitHandler.php'); 67 | ExitHandler::init(); 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHPUnit-Selenium [![Build Status](https://travis-ci.org/giorgiosironi/phpunit-selenium.svg?branch=master)](https://travis-ci.org/giorgiosironi/phpunit-selenium) 2 | 3 | This package contains a Selenium2TestCase class that can be used to run end-to-end tests against Selenium 2. 4 | 5 | Installing 6 | --- 7 | 8 | Use [Composer](https://getcomposer.org) and run `composer require --dev phpunit/phpunit-selenium`. 9 | 10 | Requirements 11 | --- 12 | 13 | - Version `9.x` supports PHPUnit 9.x and is compatible with PHP 7.3+ 14 | - Version `8.x` supports PHPUnit 8.x and is compatible with PHP 7.2+ 15 | - Version `7.x` supports PHPUnit 7.x and is compatible with PHP 7.1+ 16 | 17 | Older unsupported lines which will probably see no new releases: 18 | 19 | - `4.x` mainline supports (only) PHPUnit 6.x. This version is only compatible with PHP 7 20 | - `3.x`: supports PHPUnit 5.x. Only compatible with PHP 5.6 and PHP 7. 21 | - `2.x`: supports PHPUnit >= 4.8 instead. 22 | 23 | Both these supported lines only work with the Selenium 2 API, using the `Selenium2TestCase` class. 24 | 25 | The old line `1.x` is not maintained anymore, but will continue to be available for usage of `SeleniumTestCase`. 26 | 27 | Please direct pull requests to [giorgiosironi/phpunit-selenium](https://github.com/giorgiosironi/phpunit-selenium) for automated testing upon merging. Pull requests should be feature branches containing all the commits you want to propose. 28 | 29 | Running the test suite 30 | --- 31 | 32 | #### Via Vagrant 33 | 34 | Just run the following Vagrant commands (a minimal version of `v1.7` is required) and everything will be set up for you. The first start will take some time which depends on the speed of your connection (and less - speed of your computer): 35 | 36 | vagrant up 37 | vagrant provision 38 | vagrant ssh 39 | 40 | cd /vagrant 41 | vendor/bin/phpunit Tests 42 | 43 | -------------------------------------------------------------------------------- /Tests/CodeCoverageTest.php: -------------------------------------------------------------------------------- 1 | markTestIncomplete('Would require PHP 5.4 for running .php files on the server'); 14 | $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); 15 | $this->setBrowserUrl('http://localhost/'); 16 | } 17 | 18 | public function testCoverageIsRetrieved() 19 | { 20 | $this->url('example.php'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/BaseTestCase.php: -------------------------------------------------------------------------------- 1 | setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); 12 | $this->setPort((int)PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PORT); 13 | $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); 14 | if (!defined('PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL')) { 15 | $this->markTestSkipped("You must serve the selenium-1-tests folder from an HTTP server and configure the PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL constant accordingly."); 16 | } 17 | $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/Coverage/CookieTest.php: -------------------------------------------------------------------------------- 1 | createResult(); 18 | } 19 | if (!$result->getCollectCodeCoverageInformation()) { 20 | $result->setCodeCoverage(new \SebastianBergmann\CodeCoverage\CodeCoverage()); 21 | } 22 | 23 | parent::run($result); 24 | 25 | $result->getCodeCoverage()->clear(); 26 | return $result; 27 | } 28 | 29 | protected function getTestIdCookie() 30 | { 31 | return $this->prepareSession()->cookie()->get('PHPUNIT_SELENIUM_TEST_ID'); 32 | } 33 | 34 | public function testTestIdCookieIsSet() 35 | { 36 | $this->url('/'); 37 | $testIdCookie = $this->getTestIdCookie(); 38 | $this->assertNotEmpty($testIdCookie); 39 | return $testIdCookie; 40 | } 41 | 42 | /** 43 | * @depends testTestIdCookieIsSet 44 | */ 45 | public function testTestsHaveUniqueTestIdCookies($previousTestIdCookie) 46 | { 47 | $this->url('/'); 48 | $this->assertNotEquals($this->getTestIdCookie(), $previousTestIdCookie); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/Coverage/DummyClass.php: -------------------------------------------------------------------------------- 1 | get(); 18 | $dummyClassSourceFile = $this->classSourceFile('DummyClass', $content); 19 | $expectedCoverage = array( 20 | 3 => 1, 21 | 6 => 1, 22 | 7 => -2, 23 | 11 => -1, 24 | 12 => -2, 25 | 14 => 1 26 | ); 27 | $this->assertTrue(isset($content[$dummyClassSourceFile]), "Coverage: " . var_export($content, true)); 28 | $this->assertEquals($expectedCoverage, $content[$dummyClassSourceFile]); 29 | } 30 | 31 | private function classSourceFile($className, array $content) 32 | { 33 | foreach ($content as $file => $coverage) { 34 | if (strstr($file, $className)) { 35 | return $file; 36 | } 37 | } 38 | $this->fail("Class $className not found in coverage: " . var_export($content, true)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/Coverage/SingleFileTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Needs xdebug to run'); 15 | } 16 | $this->coverageFilePattern = __DIR__ . '/*.' . $this->dummyTestId; 17 | $this->dummyClassSourceFile = __DIR__ . '/DummyClass.php'; 18 | } 19 | 20 | public function testExecutingAFileWithThePrependedAndAppendedCoverageScriptsProducesACoverageData() 21 | { 22 | $this->clearCoverageFiles(); 23 | 24 | exec('php ' . __DIR__ . '/singleFile.php'); 25 | $coverageFiles = glob($this->coverageFilePattern); 26 | $this->assertEquals(1, count($coverageFiles)); 27 | 28 | $content = unserialize(file_get_contents($coverageFiles[0])); 29 | $dummyClassCoverage = $content[$this->dummyClassSourceFile]; 30 | $this->assertCovered(6, $dummyClassCoverage); 31 | $this->assertNotCovered(11, $dummyClassCoverage); 32 | 33 | return $dummyClassCoverage; 34 | } 35 | 36 | /** 37 | * @depends testExecutingAFileWithThePrependedAndAppendedCoverageScriptsProducesACoverageData 38 | */ 39 | public function testTheCoverageScriptReturnsTheContentOfASpecificCoverageFile($expectedDummyClassCoverage) 40 | { 41 | $coverage = unserialize(exec('php ' . __DIR__ . '/singleFileCoverage.php ' . $this->dummyTestId)); 42 | $dummyClassCoverage = $coverage[$this->dummyClassSourceFile]; 43 | $this->assertEquals($expectedDummyClassCoverage, $dummyClassCoverage['coverage']); 44 | } 45 | 46 | private function clearCoverageFiles() 47 | { 48 | $coverageFiles = glob($this->coverageFilePattern); 49 | foreach ($coverageFiles as $file) { 50 | unlink($file); 51 | } 52 | } 53 | 54 | private function assertCovered($line, array $fileCoverage) 55 | { 56 | $this->assertEquals(1, $fileCoverage[$line]); 57 | } 58 | 59 | private function assertNotCovered($line, array $fileCoverage) 60 | { 61 | $this->assertEquals(-1, $fileCoverage[$line]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/Coverage/singleFile.php: -------------------------------------------------------------------------------- 1 | coveredMethod(); 8 | 9 | require __DIR__ . '/../../../PHPUnit/Extensions/SeleniumCommon/append.php'; 10 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/Coverage/singleFileCoverage.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 2010-2013 Sebastian Bergmann 11 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 12 | * @link http://www.phpunit.de/ 13 | */ 14 | class CustomDesiredCapabilitiesTest extends BaseTestCase 15 | { 16 | public function setUp(): void 17 | { 18 | parent::setUp(); 19 | $this->setDesiredCapabilities(array( 20 | 'platform' => 'ANY' 21 | )); 22 | } 23 | 24 | public function testOpen() 25 | { 26 | $this->url('html/test_open.html'); 27 | $this->assertStringEndsWith('html/test_open.html', $this->url()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/PageObjectTest.php: -------------------------------------------------------------------------------- 1 | url('html/test_type_page1.html'); 10 | $page = new AuthenticationPage($this); 11 | $welcomePage = $page->username('TestUser') 12 | ->password('TestPassword') 13 | ->submit(); 14 | $welcomePage->assertWelcomeIs('Welcome, TestUser!'); 15 | } 16 | } 17 | 18 | class AuthenticationPage 19 | { 20 | public function __construct($test) 21 | { 22 | $this->usernameInput = $test->byName('username'); 23 | $this->passwordInput = $test->byName('password'); 24 | $this->test = $test; 25 | } 26 | 27 | public function username($value) 28 | { 29 | $this->usernameInput->value($value); 30 | return $this; 31 | } 32 | 33 | public function password($value) 34 | { 35 | $this->passwordInput->value($value); 36 | return $this; 37 | } 38 | 39 | public function submit() 40 | { 41 | $this->test->clickOnElement('submitButton'); 42 | return new WelcomePage($this->test); 43 | } 44 | } 45 | 46 | class WelcomePage 47 | { 48 | public function __construct($test) 49 | { 50 | $this->header = $test->byCssSelector('h2'); 51 | $this->test = $test; 52 | } 53 | 54 | public function assertWelcomeIs($text) 55 | { 56 | $this->test->assertMatchesRegularExpression("/$text/", $this->header->text()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/RegressionsTest.php: -------------------------------------------------------------------------------- 1 | . 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 15 | * * Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 18 | * * Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in 20 | * the documentation and/or other materials provided with the 21 | * distribution. 22 | * 23 | * * Neither the name of Sebastian Bergmann nor the names of his 24 | * contributors may be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * @package PHPUnit_Selenium 41 | * @author Giorgio Sironi 42 | * @copyright 2010-2013 Sebastian Bergmann 43 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 44 | * @link http://www.phpunit.de/ 45 | */ 46 | 47 | /** 48 | * Tests for PHPUnit_Extensions_SeleniumTestCase. 49 | * 50 | * @package PHPUnit_Selenium 51 | * @author Giorgio Sironi 52 | * @copyright 2010-2013 Sebastian Bergmann 53 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 54 | * @link http://www.phpunit.de/ 55 | */ 56 | class RegressionsTest extends BaseTestCase 57 | { 58 | /** 59 | * @return string 60 | */ 61 | public function testDependency() 62 | { 63 | $this->url("html/test_open.html"); 64 | $title = $this->title(); 65 | $this->assertEquals('Test open', $title); 66 | return $title; 67 | } 68 | 69 | /** 70 | * @depends testDependency 71 | * Checks #82 for Selenium2TestCase. 72 | * 73 | * @param $expectedTitle 74 | */ 75 | public function testDependent($expectedTitle) 76 | { 77 | $this->url("html/test_open.html"); 78 | $actualTitle = $this->title(); 79 | $this->assertSame($expectedTitle, $actualTitle); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/ScreenshotListenerTest.php: -------------------------------------------------------------------------------- 1 | directory = sys_get_temp_dir(); 20 | $existing = glob("$this->directory/Tests_Selenium2TestCase_ScreenshotListenerTest__*.png"); 21 | foreach ($existing as $file) { 22 | unlink($file); 23 | } 24 | $this->listener = new ScreenshotListener( 25 | $this->directory 26 | ); 27 | } 28 | 29 | public function testStoresAScreenshotInCaseOfError() 30 | { 31 | $this->url('html/test_open.html'); 32 | 33 | $this->listener->addError($this, new Exception(), microtime(true)); 34 | 35 | $this->assertThereIsAScreenshotNamed('Tests_Selenium2TestCase_ScreenshotListenerTest__testStoresAScreenshotInCaseOfError__*.png'); 36 | } 37 | 38 | public function testStoresAScreenshotInCaseOfFailure() 39 | { 40 | $this->url('html/test_open.html'); 41 | 42 | $exception = new AssertionFailedError(); 43 | $this->listener->addFailure($this, $exception, microtime(true)); 44 | 45 | $this->assertThereIsAScreenshotNamed('Tests_Selenium2TestCase_ScreenshotListenerTest__testStoresAScreenshotInCaseOfFailure*.png'); 46 | } 47 | 48 | public function testScreenshotGenerationMayFailWithoutJeopardizingTheRestOfTheSuite() 49 | { 50 | $test = new Tests_Selenium2TestCase_NotCapableOfTakingScreenshotsTest(); 51 | 52 | $this->listener->addError($test, new RuntimeException(), microtime(true)); 53 | $this->addToAssertionCount(1); 54 | } 55 | 56 | private function assertThereIsAScreenshotNamed($filename) 57 | { 58 | $images = glob("$this->directory/$filename"); 59 | $this->assertEquals(1, count($images), 'No screenshot were saved.'); 60 | } 61 | } 62 | 63 | /** 64 | * This Mock cannot be generated by PHPUnit because currentScreenshot() 65 | * is a method exposed via __call(). 66 | */ 67 | class Tests_Selenium2TestCase_NotCapableOfTakingScreenshotsTest extends Selenium2TestCase 68 | { 69 | public function __construct() {} 70 | 71 | public function currentScreenshot() { throw new RuntimeException(); } 72 | } 73 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/SessionCommand/FileTest.php: -------------------------------------------------------------------------------- 1 | markTestIncomplete("Cannot get this to run reliablyat all on Travis CI."); 12 | $this->url('php/file_upload.php'); 13 | 14 | $remote_file = $this->file('selenium-1-tests/html/banner.gif'); 15 | 16 | $this->byName('upload_here') 17 | ->value($remote_file); 18 | 19 | $this->byId('submit') 20 | ->click(); 21 | 22 | $msg_displayed = $this->byId('uploaded') 23 | ->displayed(); 24 | 25 | $this->assertNotEmpty($msg_displayed); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/SessionInSetupTest.php: -------------------------------------------------------------------------------- 1 | setHost(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_HOST); 12 | $this->setPort((int)PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PORT); 13 | $this->setBrowser(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM2_BROWSER); 14 | $this->setBrowserUrl(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_TESTS_URL); 15 | $this->prepareSession(); 16 | $this->url('html/test_open.html'); 17 | } 18 | 19 | public function testTheSessionStartedInSetupAndCanBeUsedNow() 20 | { 21 | $this->assertStringEndsWith('html/test_open.html', $this->url()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/SetUpPageTest.php: -------------------------------------------------------------------------------- 1 | . 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 15 | * * Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 18 | * * Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in 20 | * the documentation and/or other materials provided with the 21 | * distribution. 22 | * 23 | * * Neither the name of Sebastian Bergmann nor the names of his 24 | * contributors may be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * @package PHPUnit_Selenium 41 | * @author Julian Seeger 42 | * @copyright 2010-2013 Sebastian Bergmann 43 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 44 | * @link http://www.phpunit.de/ 45 | */ 46 | 47 | /** 48 | * @package PHPUnit_Selenium 49 | * @author Julian Seeger 50 | * @copyright 2010-2013 Sebastian Bergmann 51 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 52 | * @link http://www.phpunit.de/ 53 | */ 54 | class SetUpPageTest extends BaseTestCase { 55 | public function setUpPage() 56 | { 57 | $this->url('html/test_type_page1.html'); 58 | } 59 | 60 | public function testSetUpPageIsExecuted() 61 | { 62 | $this->assertMatchesRegularExpression('/html\/test_type_page1\.html$/', $this->url()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/SuiteBuildingTest.php: -------------------------------------------------------------------------------- 1 | . 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 15 | * * Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 18 | * * Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in 20 | * the documentation and/or other materials provided with the 21 | * distribution. 22 | * 23 | * * Neither the name of Sebastian Bergmann nor the names of his 24 | * contributors may be used to endorse or promote products derived 25 | * from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * @package PHPUnit_Selenium 41 | * @author Giorgio Sironi 42 | * @copyright 2010-2013 Sebastian Bergmann 43 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 44 | * @link http://www.phpunit.de/ 45 | */ 46 | 47 | use PHPUnit\Framework\TestCase; 48 | use PHPUnit\Framework\TestSuite; 49 | use Tests\Selenium2TestCase\fixtures\MultipleBrowsersTestCaseSample; 50 | use Tests\Selenium2TestCase\fixtures\TestCaseSample; 51 | 52 | require_once 'PHPUnit/Extensions/Selenium2TestCase.php'; 53 | 54 | /** 55 | * Tests for Selenium2TestCase::suite(). 56 | * 57 | * @package PHPUnit_Selenium 58 | * @author Jonathan Lipps 59 | * @copyright 2010-2013 Sebastian Bergmann 60 | * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License 61 | * @link http://www.phpunit.de/ 62 | */ 63 | class SuiteBuildingTest extends TestCase 64 | { 65 | public function testSampleTestCaseBuildsAFullSuiteContainingAllItsTests() 66 | { 67 | require_once __DIR__ . '/fixtures/SuiteBuildingSuites.php'; 68 | $suite = TestCaseSample::suite(TestCaseSample::class); 69 | $this->assertInstanceOf(TestSuite::class, $suite); 70 | $this->assertEquals(2, count($suite->tests())); 71 | } 72 | 73 | public function testAMultipleBrowsersTestCaseBuildsACopyOfEachTestForEachBrowser() 74 | { 75 | require_once __DIR__ . '/fixtures/SuiteBuildingSuites.php'; 76 | $suite = MultipleBrowsersTestCaseSample::suite(MultipleBrowsersTestCaseSample::class); 77 | $this->assertInstanceOf(TestSuite::class, $suite); 78 | $this->assertEquals(2, count($suite->tests())); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/TimeoutTest.php: -------------------------------------------------------------------------------- 1 | setSeleniumServerRequestsTimeout(60); 11 | } 12 | 13 | public function testOpen() 14 | { 15 | $this->url('html/test_open.html'); 16 | $this->assertStringEndsWith('html/test_open.html', $this->url()); 17 | } 18 | 19 | public function testAnImplicitWaitValueToRespectOnTheServerMustBeSmallerThanTheSeleniumServerCallsTimeout() 20 | { 21 | $this->expectException(\PHPUnit\Extensions\Selenium2TestCase\Exception::class); 22 | $this->timeouts()->implicitWait(120000); 23 | } 24 | 25 | public function testGetLastImplicitWaitValue() 26 | { 27 | $this->assertEquals(0, $this->timeouts()->getLastImplicitWaitValue()); 28 | $this->timeouts()->implicitWait(42); 29 | $this->assertEquals(42, $this->timeouts()->getLastImplicitWaitValue()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Tests/Selenium2TestCase/fixtures/SuiteBuildingSuites.php: -------------------------------------------------------------------------------- 1 | 'firefox', 18 | 'host' => 'localhost', 19 | 'port' => 4444, 20 | ), 21 | array( 22 | 'browserName' => 'safari', 23 | 'host' => 'localhost', 24 | 'port' => 4444, 25 | ), 26 | ); 27 | 28 | public function testSingle() {} 29 | } 30 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | $setupEnvironment = <<-SCRIPT 4 | 5 | cd /vagrant 6 | 7 | source ./.ci/vagrant_pre_setup.sh 8 | 9 | source ./.ci/common_env.sh 10 | source ./.ci/vagrant_env.sh 11 | 12 | source ./.ci/setup.sh 13 | 14 | source ./.ci/start.sh 15 | 16 | SCRIPT 17 | 18 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 19 | config.vm.box = "ubuntu/xenial64" 20 | config.vm.provider "virtualbox" do |v| 21 | v.memory = 2048 22 | v.cpus = 2 23 | end 24 | 25 | config.vm.provision "shell", inline: $setupEnvironment 26 | end 27 | -------------------------------------------------------------------------------- /build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php: -------------------------------------------------------------------------------- 1 | getTokens(); 12 | 13 | if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE || 14 | $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { 15 | 16 | $phpcsFile->addError( 17 | 'Concatenation operator must be surrounded by whitespace', 18 | $stackPtr 19 | ); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/PHPCS/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sebastian Bergmann's coding standard 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 | -------------------------------------------------------------------------------- /build/phpmd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | Sebastian Bergmann's ruleset 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phpunit/phpunit-selenium", 3 | "description": "Selenium Server integration for PHPUnit", 4 | "type": "library", 5 | "keywords": [ 6 | "xunit", 7 | "phpunit", 8 | "testing", 9 | "selenium" 10 | ], 11 | "homepage": "https://github.com/giorgiosironi/phpunit-selenium", 12 | "license": "BSD-3-Clause", 13 | "authors": [ 14 | { 15 | "name": "Giorgio Sironi", 16 | "email": "info@giorgiosironi.com", 17 | "role": "developer" 18 | }, 19 | { 20 | "name": "Ivan Kurnosov", 21 | "email": "zerkms@zerkms.com", 22 | "role": "developer" 23 | }, 24 | { 25 | "name": "Paul Briton", 26 | "role": "developer" 27 | }, 28 | { 29 | "name": "Patrik Štrba", 30 | "role": "developer" 31 | }, 32 | { 33 | "name": "Petr Kotek", 34 | "role": "developer" 35 | }, 36 | { 37 | "name": "Sebastian Bergmann", 38 | "email": "sb@sebastian-bergmann.de", 39 | "role": "original developer" 40 | } 41 | ], 42 | "support": { 43 | "issues": "https://github.com/giorgiosironi/phpunit-selenium/issues" 44 | }, 45 | "require": { 46 | "php": ">=7.3", 47 | "ext-curl": "*", 48 | "phpunit/phpunit": ">=9.0,<10.0" 49 | }, 50 | "require-dev": { 51 | "phing/phing": "2.*" 52 | }, 53 | "autoload": { 54 | "classmap": [ 55 | "PHPUnit/" 56 | ] 57 | }, 58 | "include-path": [ 59 | "" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /phpunit-selenium-bootstrap.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 25 | 26 | 27 | 28 | Tests 29 | 30 | 31 | 32 | 33 | 34 | PHPUnit 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /selenium-1-tests/coverage/dummy.html: -------------------------------------------------------------------------------- 1 | a:3:{s:85:"/home/giorgio/code/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/ExitHandler.php";a:2:{s:3:"md5";s:32:"9da156828a8b6591d6905664624e29fb";s:8:"coverage";a:9:{i:10;i:1;i:18;i:1;i:19;i:1;i:26;i:-1;i:27;i:-1;i:28;i:-1;i:29;i:-1;i:30;i:-1;i:32;i:1;}}s:83:"/home/giorgio/code/phpunit-selenium/Tests/Selenium2TestCase/Coverage/DummyClass.php";a:2:{s:3:"md5";s:32:"7c8088a34547c159e7bf27f792211bb6";s:8:"coverage";a:6:{i:3;i:1;i:6;i:1;i:7;i:-2;i:11;i:-1;i:12;i:-2;i:14;i:1;}}s:83:"/home/giorgio/code/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFile.php";a:2:{s:3:"md5";s:32:"01983b91b1db9d6d59e48111c6b0fe5a";s:8:"coverage";a:4:{i:5;i:1;i:6;i:1;i:7;i:1;i:9;i:1;}}} 2 | -------------------------------------------------------------------------------- /selenium-1-tests/coverage/dummy.txt: -------------------------------------------------------------------------------- 1 | a:3:{s:85:"/home/giorgio/code/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/ExitHandler.php";a:2:{s:3:"md5";s:32:"9da156828a8b6591d6905664624e29fb";s:8:"coverage";a:9:{i:10;i:1;i:18;i:1;i:19;i:1;i:26;i:-1;i:27;i:-1;i:28;i:-1;i:29;i:-1;i:30;i:-1;i:32;i:1;}}s:83:"/home/giorgio/code/phpunit-selenium/Tests/Selenium2TestCase/Coverage/DummyClass.php";a:2:{s:3:"md5";s:32:"7c8088a34547c159e7bf27f792211bb6";s:8:"coverage";a:6:{i:3;i:1;i:6;i:1;i:7;i:-2;i:11;i:-1;i:12;i:-2;i:14;i:1;}}s:83:"/home/giorgio/code/phpunit-selenium/Tests/Selenium2TestCase/Coverage/singleFile.php";a:2:{s:3:"md5";s:32:"01983b91b1db9d6d59e48111c6b0fe5a";s:8:"coverage";a:4:{i:5;i:1;i:6;i:1;i:7;i:1;i:9;i:1;}}} 2 | -------------------------------------------------------------------------------- /selenium-1-tests/html/CamelCasePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CamelCase page 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /selenium-1-tests/html/banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/giorgiosironi/phpunit-selenium/b40dc292627e5de5bd8d32570627a6d55b2b846c/selenium-1-tests/html/banner.gif -------------------------------------------------------------------------------- /selenium-1-tests/html/test_check_uncheck.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | banner
22 | 23 |

Test for management of check-box and radio-button inputs

24 | 25 |
26 | 27 |
28 | Base 29 | Baked Potato
30 | Steamed Rice
31 | Tortilla
32 |
33 | 34 |
35 | Options 36 | Beans
37 | Butter
38 | Cheese
39 | Chilli Flakes
40 | Onions
41 | Sour Cream
42 |
43 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_click_javascript_page.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Click Page 1 19 | 24 | 25 | 26 | link
27 |
28 |
29 | link with void href
30 | link with onclick returns false
31 | link with multiple javascript calls
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_click_page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Click Page 1 19 | 21 | 22 | 23 | Click here for next page
24 | Click here for next page via absolute link
25 |
26 | link to other link
27 | link with onclick="return false"
28 | 29 | 30 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_click_page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Click Page Target 19 | 21 | 22 | 23 | This is a test of the click command. 24 | 25 |
26 |
27 | Return to test_click_page1.html 28 | 29 | 30 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_confirm.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 28 | Test Confirm 29 | 30 | 31 | banner
32 | click to navigate to a new page 33 | 34 | 35 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_count.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test count 4 | 5 | 6 | This is a test of the count* commands. 7 | 8 |
    9 |
  • 1
  • 10 |
  • 2
  • 11 |
  • 3
  • 12 |
  • 4
  • 13 |
  • 5
  • 14 |
  • 6
  • 15 |
  • 7
  • 16 |
  • 8
  • 17 |
  • 9
  • 18 |
  • 10
  • 19 |
  • 11
  • 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_delayed_element.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Delayed element 5 | 18 | 19 | 20 | banner
21 |

This is a page with slow-loading (delayed) element.

22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /selenium-1-tests/html/test_doubleclick.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Doubleclick Page 19 | 29 | 30 | 31 |