Skip to content
Closed

W3c #599

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
22b6428
add W3C support
Jul 16, 2018
a02f009
remove parameter '-enablePassThrough'
Sep 3, 2018
2527c47
update travis
Sep 3, 2018
0f82fd9
add geckodriver
Sep 3, 2018
4f3e7f3
fix geckodriver
Sep 3, 2018
0cc60b7
fix geckodriver
Sep 3, 2018
09977fa
fix geckodriver
Sep 3, 2018
a4bc04d
fix geckodriver
Sep 3, 2018
6dc43c6
fix geckodriver
Sep 3, 2018
a1d1def
fix geckodriver
Sep 3, 2018
abec001
fix geckodriver
Sep 3, 2018
503312d
fix geckodriver
Sep 3, 2018
05a96d2
fix chrome tests
Sep 3, 2018
5b28f9b
add chrome_headles version to travis tests
Sep 3, 2018
333cc49
fix
Sep 3, 2018
16fec6f
fix some issues
Sep 4, 2018
6d07b5e
fix analyze
Sep 4, 2018
d41378d
add unit tests
Sep 18, 2018
d53a773
fix code style
Sep 18, 2018
75a14bf
fix codestyle
Sep 18, 2018
b2be168
fix codestyle
Sep 18, 2018
98f8e7f
fix codestyle
Sep 18, 2018
9322010
fix codestyle
Sep 18, 2018
c5477a8
fix codestyle
Sep 18, 2018
b750cf5
update travis
Sep 18, 2018
dc09e1d
update travis
Sep 18, 2018
a5ef18f
update travis and licence
Sep 18, 2018
48bb741
update firefox version for travis
Sep 18, 2018
faa141d
update travis
Sep 18, 2018
d749237
update phpunit version
Sep 19, 2018
e5af60f
overwrite capabilities for firefox in functional test client
Sep 19, 2018
b7a9643
refactor Executor and add function tests to manage window
Sep 20, 2018
f9f4acf
fix coverage phpdoc
Sep 20, 2018
7cd95d6
fix covers
Sep 20, 2018
a3a3e3a
fix codestyle
Sep 20, 2018
b0141b7
fix code after analyze
Sep 21, 2018
361b4fa
update ff verstion in travis
Sep 21, 2018
3aeb2e2
fix tests and change ff to headless mode
Sep 21, 2018
a3592f6
fix command line script phpunit
Sep 21, 2018
de2c535
fix command line script phpunit
Sep 21, 2018
9ddf2be
add support for native geckodriver
Oct 2, 2018
a9ddb5a
fix travis conf
Oct 2, 2018
db5694b
fix travis yml
Oct 2, 2018
ba2b863
fix travis yml
Oct 2, 2018
2a5fb7e
tavis
Oct 2, 2018
64d10cb
tavis
Oct 2, 2018
95812c5
tavis
Oct 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ env:
- DISPLAY=:99.0
- BROWSER_NAME="htmlunit"
- CHROMEDRIVER_VERSION="2.38"
- GECKODRIVER_VERSION="0.22.0"

matrix:
include:
# Add build to run tests against Firefox inside Travis environment
- php: 7.2
env: BROWSER_NAME="firefox"
env: BROWSER_NAME="firefox" MOZ_HEADLESS="1"
addons:
firefox: "45.8.0esr"
firefox: "latest"

# Add build to run tests against Firefox inside Travis environment with native geckodriver
- php: 7.2
env: BROWSER_NAME="firefox" GECKODRIVER="1" MOZ_HEADLESS="1"
addons:
firefox: "latest"

# Add build to run tests against Chrome inside Travis environment
- php: 7.2
Expand All @@ -40,7 +47,7 @@ matrix:

# Saucelabs builds
- php: 7.2
env: SAUCELABS=1 BROWSER_NAME="firefox" VERSION="47.0" PLATFORM="Windows 10"
env: SAUCELABS=1 BROWSER_NAME="firefox" VERSION="61.0" PLATFORM="Windows 10"
before_script:
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
Expand All @@ -58,7 +65,7 @@ matrix:
jwt:
secure: HPq5xFhosa1eSGnaRdJzeyEuaE0mhRlG1gf3G7+dKS0VniF30husSyrxZhbGCCKBGxmIySoAQzd43BCwL69EkUEVKDN87Cpid1Ce9KrSfU3cnN8XIb+4QINyy7x1a47RUAfaaOEx53TrW0ShalvjD+ZwDE8LrgagSox6KQ+nQLE=
- php: 7.2
env: SAUCELABS=1 BROWSER_NAME="MicrosoftEdge" VERSION="15.15063" PLATFORM="Windows 10"
env: SAUCELABS=1 BROWSER_NAME="MicrosoftEdge" VERSION="latest" PLATFORM="Windows 10"
before_script:
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
Expand Down Expand Up @@ -92,9 +99,17 @@ install:
before_script:
- if [ "$BROWSER_NAME" = "chrome" ]; then mkdir chromedriver; wget -q -t 3 https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip; unzip chromedriver_linux64 -d chromedriver; fi
- if [ "$BROWSER_NAME" = "chrome" ]; then export CHROMEDRIVER_PATH=$PWD/chromedriver/chromedriver; fi
- if [ "$BROWSER_NAME" = "firefox" ]; then mkdir geckodriver; wget -q -t 3 https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz; tar -xvzf geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz -C geckodriver; chmod +x geckodriver; fi
- if [ "$BROWSER_NAME" = "firefox" ]; then export GECKODRIVER_PATH=$PWD/geckodriver/geckodriver; fi
- sh -e /etc/init.d/xvfb start
- if [ ! -f jar/selenium-server-standalone-3.8.1.jar ]; then wget -q -t 3 -P jar https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.1.jar; fi
- java -Dwebdriver.firefox.marionette=false -Dwebdriver.chrome.driver="$CHROMEDRIVER_PATH" -jar jar/selenium-server-standalone-3.8.1.jar -enablePassThrough false -log ./logs/selenium.log &
- |
if [ "$GECKODRIVER" = "1" ]
then
geckodriver/geckodriver &> ./logs/geckodriver.log &
else
if [ ! -f jar/selenium-server-standalone-3.14.0.jar ]; then wget -q -t 3 -P jar https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar; fi
java -Dwebdriver.chrome.driver="$CHROMEDRIVER_PATH" -Dwebdriver.gecko.driver="$GECKODRIVER_PATH" -jar jar/selenium-server-standalone-3.14.0.jar -log ./logs/selenium.log &
fi
- until $(echo | nc localhost 4444); do sleep 1; echo Waiting for Selenium server on port 4444...; done; echo "Selenium server started"
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
Expand Down
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
"forum": "https://www.facebook.com/groups/phpwebdriver/",
"source": "https://github.com/facebook/php-webdriver"
},
"minimum-stability": "beta",
"minimum-stability": "stable",
"require": {
"php": "^5.6 || ~7.0",
"symfony/process": "^2.8 || ^3.1 || ^4.0",
"ext-curl": "*",
"ext-zip": "*",
"ext-mbstring": "*",
"ext-json": "*"
"ext-json": "*",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^5.7.27",
"sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^2.0",
"squizlabs/php_codesniffer": "^2.6",
Expand Down Expand Up @@ -56,10 +57,5 @@
"vendor/bin/parallel-lint -j 10 ./lib ./tests",
"vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi"
]
},
"extra": {
"branch-alias": {
"dev-community": "1.5-dev"
}
}
}
21 changes: 17 additions & 4 deletions lib/Chrome/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
use Facebook\WebDriver\Exception\WebDriverException;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\DriverCommand;
use Facebook\WebDriver\Remote\ExecutableWebDriverCommand;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
use Facebook\WebDriver\Remote\WebDriverCommand;
use Facebook\WebDriver\Remote\WebDriverDialect;
use Facebook\WebDriver\Remote\WebDriverResponseFactory;
use Psr\Log\LoggerInterface;

class ChromeDriver extends RemoteWebDriver
{
Expand All @@ -36,12 +40,16 @@ public static function start(DesiredCapabilities $desired_capabilities = null, C
$service = ChromeDriverService::createDefaultService();
}
$executor = new DriverCommandExecutor($service);
$driver = new static($executor, null, $desired_capabilities);
$driver = new static($executor, WebDriverDialect::createJsonWireProtocol(), null, $desired_capabilities);
$driver->startSession($desired_capabilities);

return $driver;
}

/**
* @param DesiredCapabilities $desired_capabilities
* @throws WebDriverException
*/
public function startSession(DesiredCapabilities $desired_capabilities)
{
$command = new WebDriverCommand(
Expand All @@ -51,7 +59,9 @@ public function startSession(DesiredCapabilities $desired_capabilities)
'desiredCapabilities' => $desired_capabilities->toArray(),
]
);
$response = $this->executor->execute($command);
$result = $this->executor->execute(ExecutableWebDriverCommand::getNewSessionCommand($command));
$response = WebDriverResponseFactory::create($result);

$this->sessionID = $response->getSessionID();
}

Expand All @@ -65,8 +75,8 @@ public function startSession(DesiredCapabilities $desired_capabilities)
* @param string|null $http_proxy
* @param int|null $http_proxy_port
* @param DesiredCapabilities $required_capabilities
* @param LoggerInterface|null $logger
* @throws WebDriverException
* @return RemoteWebDriver
*/
public static function create(
$selenium_server_url = 'http://localhost:4444/wd/hub',
Expand All @@ -75,7 +85,8 @@ public static function create(
$request_timeout_in_ms = null,
$http_proxy = null,
$http_proxy_port = null,
DesiredCapabilities $required_capabilities = null
DesiredCapabilities $required_capabilities = null,
LoggerInterface $logger = null
) {
throw new WebDriverException('Please use ChromeDriver::start() instead.');
}
Expand All @@ -84,6 +95,7 @@ public static function create(
* Always throws an exception. Use ChromeDriver::start() instead.
*
* @param string $session_id The existing session id
* @param WebDriverDialect $dialect
* @param string $selenium_server_url The url of the remote Selenium WebDriver server
* @param int|null $connection_timeout_in_ms Set timeout for the connect phase to remote Selenium WebDriver server
* @param int|null $request_timeout_in_ms Set the maximum time of a request to remote Selenium WebDriver server
Expand All @@ -92,6 +104,7 @@ public static function create(
*/
public static function createBySessionID(
$session_id,
WebDriverDialect $dialect,
$selenium_server_url = 'http://localhost:4444/wd/hub',
$connection_timeout_in_ms = null,
$request_timeout_in_ms = null
Expand Down
82 changes: 46 additions & 36 deletions lib/Exception/WebDriverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,7 @@ public function getResults()
* @param string $message
* @param mixed $results
*
* @throws ElementNotSelectableException
* @throws ElementNotVisibleException
* @throws ExpectedException
* @throws IMEEngineActivationFailedException
* @throws IMENotAvailableException
* @throws IndexOutOfBoundsException
* @throws InvalidCookieDomainException
* @throws InvalidCoordinatesException
* @throws InvalidElementStateException
* @throws InvalidSelectorException
* @throws MoveTargetOutOfBoundsException
* @throws NoAlertOpenException
* @throws NoCollectionException
* @throws NoScriptResultException
* @throws NoStringException
* @throws NoStringLengthException
* @throws NoStringWrapperException
* @throws NoSuchCollectionException
* @throws NoSuchDocumentException
* @throws NoSuchDriverException
* @throws NoSuchElementException
* @throws NoSuchFrameException
* @throws NoSuchWindowException
* @throws NullPointerException
* @throws ScriptTimeoutException
* @throws SessionNotCreatedException
* @throws StaleElementReferenceException
* @throws TimeOutException
* @throws UnableToSetCookieException
* @throws UnexpectedAlertOpenException
* @throws UnexpectedJavascriptException
* @throws UnknownCommandException
* @throws UnknownServerException
* @throws UnrecognizedExceptionException
* @throws WebDriverCurlException
* @throws XPathLookupException
* @throws WebDriverException
*/
public static function throwException($status_code, $message, $results)
{
Expand Down Expand Up @@ -158,4 +123,49 @@ public static function throwException($status_code, $message, $results)
throw new UnrecognizedExceptionException($message, $results);
}
}

/**
* Throw WebDriverExceptions based on WebDriver status code.
*
* @param string $error
* @param mixed $results
*
* @throws WebDriverException
*/
public static function throwExceptionForW3c($error, $results)
{
switch ($error) {
case 'element click intercepted':
case 'invalid element state':
throw new InvalidElementStateException($error, $results);
case 'element not interactable':
throw new ElementNotSelectableException($error, $results);
case 'no such element':
throw new NoSuchElementException($error, $results);
case 'timeout':
throw new TimeOutException($error, $results);
case 'script timeout':
throw new ScriptTimeoutException($error, $results);
case 'no such window':
throw new NoSuchWindowException($error, $results);
case 'invalid cookie domain':
throw new InvalidCookieDomainException($error, $results);
case 'unable to set cookie':
throw new UnableToSetCookieException($error, $results);
case 'unknown command':
throw new UnknownCommandException($error, $results);
case 'unknown error':
throw new UnknownServerException($error, $results);
case 'invalid selector':
throw new InvalidSelectorException($error, $results);
case 'move target out of bounds':
throw new MoveTargetOutOfBoundsException($error, $results);
case 'stale element reference':
throw new StaleElementReferenceException($error, $results);
case 'no such alert':
throw new NoAlertOpenException($error, $results);
default:
throw new self($error, $results);
}
}
}
12 changes: 6 additions & 6 deletions lib/Interactions/WebDriverActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Facebook\WebDriver\Interactions\Internal\WebDriverMouseMoveAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverMoveToOffsetAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverSendKeysAction;
use Facebook\WebDriver\WebDriver;
use Facebook\WebDriver\Remote\Action\WebDriverActionPerformer;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverHasInputDevices;

Expand All @@ -34,20 +34,20 @@
*/
class WebDriverActions
{
protected $driver;
protected $keyboard;
protected $mouse;
protected $action;

/**
* WebDriverActions constructor.
* @param WebDriverHasInputDevices $driver
* @param WebDriverActionPerformer $performer
*/
public function __construct(WebDriverHasInputDevices $driver)
public function __construct(WebDriverHasInputDevices $driver, WebDriverActionPerformer $performer)
{
$this->driver = $driver;
$this->keyboard = $driver->getKeyboard();
$this->mouse = $driver->getMouse();
$this->action = new WebDriverCompositeAction();
$this->keyboard = $driver->getKeyboard();
$this->action = new WebDriverCompositeAction($performer);
}

/**
Expand Down
19 changes: 16 additions & 3 deletions lib/Interactions/WebDriverCompositeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,33 @@

namespace Facebook\WebDriver\Interactions;

use Facebook\WebDriver\Remote\Action\WebDriverActionPerformer;
use Facebook\WebDriver\WebDriverAction;

/**
* An action for aggregating actions and triggering all of them afterwards.
*/
class WebDriverCompositeAction implements WebDriverAction
{
/**
* @var WebDriverActionPerformer
*/
private $performer;

/**
* @var WebDriverAction[]
*/
private $actions = [];

/**
* WebDriverCompositeAction constructor.
* @param WebDriverActionPerformer $performer
*/
public function __construct(WebDriverActionPerformer $performer)
{
$this->performer = $performer;
}

/**
* Add an WebDriverAction to the sequence.
*
Expand Down Expand Up @@ -55,8 +70,6 @@ public function getNumberOfActions()
*/
public function perform()
{
foreach ($this->actions as $action) {
$action->perform();
}
$this->performer->perform($this->actions);
}
}
6 changes: 4 additions & 2 deletions lib/Interactions/WebDriverTouchActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
use Facebook\WebDriver\Interactions\Touch\WebDriverScrollFromElementAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverTapAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverTouchScreen;
use Facebook\WebDriver\Remote\Action\WebDriverActionPerformer;
use Facebook\WebDriver\WebDriver;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverHasInputDevices;
use Facebook\WebDriver\WebDriverUpAction;

/**
Expand All @@ -39,9 +41,9 @@ class WebDriverTouchActions extends WebDriverActions
*/
protected $touchScreen;

public function __construct(WebDriver $driver)
public function __construct(WebDriverHasInputDevices $driver, WebDriverActionPerformer $performer)
{
parent::__construct($driver);
parent::__construct($driver, $performer);
$this->touchScreen = $driver->getTouch();
}

Expand Down
Loading