Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
added facebook selenium webdriver
  • Loading branch information
individual-it committed Jan 27, 2017
commit 465541316844e9ffbe86c7d025125741c6a975d6
105 changes: 105 additions & 0 deletions tests/vendor/facebook/webdriver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
php-webdriver -- WebDriver bindings for PHP
===========================================

## DESCRIPTION

This WebDriver client aims to be as close as possible to bindings in other languages. The concepts are very similar to the Java, .NET, Python and Ruby bindings for WebDriver.

Looking for documentation about php-webdriver? See http://facebook.github.io/php-webdriver/

The PHP client was rewritten from scratch. Using the old version? Check out Adam Goucher's fork of it at https://github.com/Element-34/php-webdriver

Any complaint, question, idea? You can post it on the user group https://www.facebook.com/groups/phpwebdriver/.

## GETTING THE CODE

### Github
git clone [email protected]:facebook/php-webdriver.git

### Packagist
Add the dependency. https://packagist.org/packages/facebook/webdriver

{
"require": {
"facebook/webdriver": "dev-master"
}
}

Download the composer.phar

curl -sS https://getcomposer.org/installer | php

Install the library.

php composer.phar install



## GETTING STARTED

* All you need as the server for this client is the selenium-server-standalone-#.jar file provided here: http://selenium-release.storage.googleapis.com/index.html

* Download and run that file, replacing # with the current server version.

java -jar selenium-server-standalone-#.jar

* Then when you create a session, be sure to pass the url to where your server is running.

// This would be the url of the host running the server-standalone.jar
$host = 'http://localhost:4444/wd/hub'; // this is the default

* Launch Firefox

$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());

* Launch Chrome

$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());

* You can also customize the desired capabilities.

$desired_capabilities = DesiredCapabilities::firefox();
$desired_capabilities->setJavascriptEnabled(false);
RemoteWebDriver::create($host, $desired_capabilities);

* See https://code.google.com/p/selenium/wiki/DesiredCapabilities for more details.

## RUN UNIT TESTS

To run unit tests simply run:

./vendor/bin/phpunit -c ./tests

Note: For the functional test suite, a running selenium server is required.

## MORE INFORMATION

Check out the Selenium docs and wiki at http://docs.seleniumhq.org/docs/ and https://code.google.com/p/selenium/wiki

Learn how to integrate it with PHPUnit [Blogpost](http://codeception.com/11-12-2013/working-with-phpunit-and-selenium-webdriver.html) | [Demo Project](https://github.com/DavertMik/php-webdriver-demo)

## SUPPORT

We have a great community willing to try and help you!

Currently we offer support in two manners:

### Via our Facebook Group

If you have questions or are an active contributor consider joining our facebook group and contributing to the communal discussion and support

https://www.facebook.com/groups/phpwebdriver/

### Via Github

If you're reading this you've already found our Github repository. If you have a question, feel free to submit it as an issue and our staff will do their best to help you as soon as possible.

## CONTRIBUTING

We love to have your help to make php-webdriver better. Feel free to

* open an [issue](https://github.com/facebook/php-webdriver/issues) if you run into any problem.
* fork the project and submit [pull request](https://github.com/facebook/php-webdriver/pulls). Before the pull requests can be accepted, a [Contributors Licensing Agreement](http://developers.facebook.com/opensource/cla) must be signed.

When you are going to contribute, please keep in mind that this webdriver client aims to be as close as possible to other languages Java/Ruby/Python/C#.
FYI, here is the overview of [the official Java API](http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html?overview-summary.html)
23 changes: 23 additions & 0 deletions tests/vendor/facebook/webdriver/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "facebook/webdriver",
"description": "A php client for WebDriver",
"keywords": ["webdriver", "selenium", "php", "facebook"],
"homepage": "https://github.com/facebook/php-webdriver",
"type": "library",
"license": "Apache-2.0",
"support": {
"issues": "https://github.com/facebook/php-webdriver/issues",
"forum": "https://www.facebook.com/groups/phpwebdriver/",
"source": "https://github.com/facebook/php-webdriver"
},
"require": {
"php": ">=5.3.19"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpdocumentor/phpdocumentor": "2.*"
},
"autoload": {
"classmap": ["lib/"]
}
}
49 changes: 49 additions & 0 deletions tests/vendor/facebook/webdriver/example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// An example of using php-webdriver.

require_once('lib/__init__.php');

// start Firefox with 5 second timeout
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);

// navigate to 'http://docs.seleniumhq.org/'
$driver->get('http://docs.seleniumhq.org/');

// adding cookie
$driver->manage()->deleteAllCookies();
$driver->manage()->addCookie(array(
'name' => 'cookie_name',
'value' => 'cookie_value',
));
$cookies = $driver->manage()->getCookies();
print_r($cookies);

// click the link 'About'
$link = $driver->findElement(
WebDriverBy::id('menu_about')
);
$link->click();

// print the title of the current page
echo "The title is " . $driver->getTitle() . "'\n";

// print the title of the current page
echo "The current URI is " . $driver->getCurrentURL() . "'\n";

// Search 'php' in the search box
$input = $driver->findElement(
WebDriverBy::id('q')
);
$input->sendKeys('php')->submit();

// wait at most 10 seconds until at least one result is shown
$driver->wait(10)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('gsc-result')
)
);

// close the Firefox
$driver->quit();
47 changes: 47 additions & 0 deletions tests/vendor/facebook/webdriver/lib/JavaScriptExecutor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* WebDriver interface implemented by drivers that support JavaScript.
*/
interface JavaScriptExecutor {

/**
* Inject a snippet of JavaScript into the page for execution in the context
* of the currently selected frame. The executed script is assumed to be
* synchronous and the result of evaluating the script will be returned.
*
* @param string $script The script to inject.
* @param array $arguments The arguments of the script.
* @return mixed The return value of the script.
*/
public function executeScript($script, array $arguments = array());

/**
* Inject a snippet of JavaScript into the page for asynchronous execution in
* the context of the currently selected frame.
*
* The driver will pass a callback as the last argument to the snippet, and
* block until the callback is invoked.
*
* @see WebDriverExecuteAsyncScriptTestCase
*
* @param string $script The script to inject.
* @param array $arguments The arguments of the script.
* @return mixed The value passed by the script to the callback.
*/
public function executeAsyncScript($script, array $arguments = array());

}
134 changes: 134 additions & 0 deletions tests/vendor/facebook/webdriver/lib/WebDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* The interface for WebDriver.
*/
interface WebDriver extends WebDriverSearchContext {

/**
* Close the current window.
*
* @return WebDriver The current instance.
*/
public function close();

/**
* Load a new web page in the current browser window.
*
* @param string $url
* @return WebDriver The current instance.
*/
public function get($url);

/**
* Get a string representing the current URL that the browser is looking at.
*
* @return string The current URL.
*/
public function getCurrentURL();

/**
* Get the source of the last loaded page.
*
* @return string The current page source.
*/
public function getPageSource();

/**
* Get the title of the current page.
*
* @return string The title of the current page.
*/
public function getTitle();

/**
* Return an opaque handle to this window that uniquely identifies it within
* this driver instance.
*
* @return string The current window handle.
*/
public function getWindowHandle();

/**
* Get all window handles available to the current session.
*
* @return array An array of string containing all available window handles.
*/
public function getWindowHandles();

/**
* Quits this driver, closing every associated window.
*
* @return void
*/
public function quit();

/**
* Take a screenshot of the current page.
*
* @param string $save_as The path of the screenshot to be saved.
* @return string The screenshot in PNG format.
*/
public function takeScreenshot($save_as = null);

/**
* Construct a new WebDriverWait by the current WebDriver instance.
* Sample usage:
*
* $driver->wait(20, 1000)->until(
* WebDriverExpectedCondition::titleIs('WebDriver Page')
* );
*
* @param int $timeout_in_second
* @param int $interval_in_millisecond
* @return WebDriverWait
*/
public function wait(
$timeout_in_second = 30,
$interval_in_millisecond = 250);

/**
* An abstraction for managing stuff you would do in a browser menu. For
* example, adding and deleting cookies.
*
* @return WebDriverOptions
*/
public function manage();

/**
* An abstraction allowing the driver to access the browser's history and to
* navigate to a given URL.
*
* @return WebDriverNavigation
* @see WebDriverNavigation
*/
public function navigate();

/**
* Switch to a different window or frame.
*
* @return WebDriverTargetLocator
* @see WebDriverTargetLocator
*/
public function switchTo();

/**
* @param string $name
* @param array $params
* @return mixed
*/
public function execute($name, $params);
}
25 changes: 25 additions & 0 deletions tests/vendor/facebook/webdriver/lib/WebDriverAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* Interface representing a single user-interaction action.
*/
interface WebDriverAction {

/**
* @return void
*/
public function perform();
}
Loading