class PhantomJSDriver in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/jcalderonzumba/mink-phantomjs-driver/src/PhantomJSDriver.php \Zumba\Mink\Driver\PhantomJSDriver
Class PhantomJSDriver @package Behat\Mink\Driver
Hierarchy
- class \Behat\Mink\Driver\CoreDriver implements DriverInterface
- class \Zumba\Mink\Driver\BasePhantomJSDriver
- class \Zumba\Mink\Driver\PhantomJSDriver uses CookieTrait, FormManipulationTrait, HeadersTrait, JavascriptTrait, KeyboardTrait, MouseTrait, NavigationTrait, PageContentTrait, SessionTrait, WindowTrait
- class \Zumba\Mink\Driver\BasePhantomJSDriver
Expanded class hierarchy of PhantomJSDriver
File
- vendor/
jcalderonzumba/ mink-phantomjs-driver/ src/ PhantomJSDriver.php, line 12
Namespace
Zumba\Mink\DriverView source
class PhantomJSDriver extends BasePhantomJSDriver {
use SessionTrait;
use NavigationTrait;
use CookieTrait;
use HeadersTrait;
use JavascriptTrait;
use MouseTrait;
use PageContentTrait;
use KeyboardTrait;
use FormManipulationTrait;
use WindowTrait;
/**
* Sets the basic auth user and password
* @param string $user
* @param string $password
*/
public function setBasicAuth($user, $password) {
$this->browser
->setHttpAuth($user, $password);
}
/**
* Gets the tag name of a given xpath
* @param string $xpath
* @return string
* @throws DriverException
*/
public function getTagName($xpath) {
$elements = $this
->findElement($xpath, 1);
return $this->browser
->tagName($elements["page_id"], $elements["ids"][0]);
}
/**
* Gets the attribute value of a given element and name
* @param string $xpath
* @param string $name
* @return string
* @throws DriverException
*/
public function getAttribute($xpath, $name) {
$elements = $this
->findElement($xpath, 1);
return $this->browser
->attribute($elements["page_id"], $elements["ids"][0], $name);
}
/**
* Check if element given by xpath is visible or not
* @param string $xpath
* @return bool
* @throws DriverException
*/
public function isVisible($xpath) {
$elements = $this
->findElement($xpath, 1);
return $this->browser
->isVisible($elements["page_id"], $elements["ids"][0]);
}
/**
* Drags one element to another
* @param string $sourceXpath
* @param string $destinationXpath
* @throws DriverException
*/
public function dragTo($sourceXpath, $destinationXpath) {
$sourceElement = $this
->findElement($sourceXpath, 1);
$destinationElement = $this
->findElement($destinationXpath, 1);
$this->browser
->drag($sourceElement["page_id"], $sourceElement["ids"][0], $destinationElement["ids"][0]);
}
/**
* Upload a file to the browser
* @param string $xpath
* @param string $path
* @throws DriverException
*/
public function attachFile($xpath, $path) {
if (!file_exists($path)) {
throw new DriverException("Wow there the file does not exist, you can not upload it");
}
if (($realPath = realpath($path)) === false) {
throw new DriverException("Wow there the file does not exist, you can not upload it");
}
$element = $this
->findElement($xpath, 1);
$tagName = $this
->getTagName($xpath);
if ($tagName != "input") {
throw new DriverException("The element is not an input element, you can not attach a file to it");
}
$attributes = $this
->getBrowser()
->attributes($element["page_id"], $element["ids"][0]);
if (!isset($attributes["type"]) || $attributes["type"] != "file") {
throw new DriverException("The element is not an input file type element, you can not attach a file to it");
}
$this->browser
->selectFile($element["page_id"], $element["ids"][0], $realPath);
}
/**
* Puts the browser control inside the IFRAME
* You own the control, make sure to go back to the parent calling this method with null
* @param string $name
*/
public function switchToIFrame($name = null) {
//TODO: check response of the calls
if ($name === null) {
$this->browser
->popFrame();
return;
}
else {
$this->browser
->pushFrame($name);
}
}
/**
* Focus on an element
* @param string $xpath
* @throws DriverException
*/
public function focus($xpath) {
$element = $this
->findElement($xpath, 1);
$this->browser
->trigger($element["page_id"], $element["ids"][0], "focus");
}
/**
* Blur on element
* @param string $xpath
* @throws DriverException
*/
public function blur($xpath) {
$element = $this
->findElement($xpath, 1);
$this->browser
->trigger($element["page_id"], $element["ids"][0], "blur");
}
/**
* Finds elements with specified XPath query.
* @param string $xpath
* @return NodeElement[]
* @throws DriverException When the operation cannot be done
*/
public function find($xpath) {
$elements = $this->browser
->find("xpath", $xpath);
$nodeElements = array();
if (!isset($elements["ids"])) {
return null;
}
foreach ($elements["ids"] as $i => $elementId) {
$nodeElements[] = new NodeElement(sprintf('(%s)[%d]', $xpath, $i + 1), $this->session);
}
return $nodeElements;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BasePhantomJSDriver:: |
protected | property | @var Browser | |
BasePhantomJSDriver:: |
protected | property | @var string | |
BasePhantomJSDriver:: |
protected | property |
@var Session Overrides CoreDriver:: |
|
BasePhantomJSDriver:: |
protected | property | @var \Twig_Environment | |
BasePhantomJSDriver:: |
protected | property | @var \Twig_Loader_Filesystem | |
BasePhantomJSDriver:: |
protected | function | Helper to find a node element given an xpath | |
BasePhantomJSDriver:: |
public | function | ||
BasePhantomJSDriver:: |
public | function | ||
BasePhantomJSDriver:: |
public | function | Returns a javascript script via twig template engine | |
BasePhantomJSDriver:: |
public | function |
Overrides CoreDriver:: |
|
BasePhantomJSDriver:: |
protected | function | Sets up the cache template location for the scripts we are going to create with the driver | |
BasePhantomJSDriver:: |
public | function | Instantiates the driver | |
CookieTrait:: |
public | function | Gets a cookie by its name if exists, else it will return null | |
CookieTrait:: |
public | function | Sets a cookie on the browser, if null value then delete it | |
CoreDriver:: |
protected | function | Finds elements with specified XPath query. | 1 |
CoreDriver:: |
public | function |
Maximizes the window if it is not maximized already. Overrides DriverInterface:: |
|
FormManipulationTrait:: |
protected | function | Helper method needed for twig and javascript stuff | |
FormManipulationTrait:: |
public | function | We click on the checkbox or radio when possible and needed | |
FormManipulationTrait:: |
public | function | Returns the value of a given xpath element | |
FormManipulationTrait:: |
protected | function | Check control over an input element of radio or checkbox type | |
FormManipulationTrait:: |
public | function | Checks if the radio or checkbox is checked | |
FormManipulationTrait:: |
public | function | Checks if the option is selected or not | |
FormManipulationTrait:: |
public | function | Selects an option | |
FormManipulationTrait:: |
public | function | ||
FormManipulationTrait:: |
public | function | Submits a form given an xpath selector | |
FormManipulationTrait:: |
public | function | We click on the checkbox or radio when possible and needed | |
HeadersTrait:: |
public | function | Gets the current request response headers Should be called only after a request, other calls are undefined behaviour | |
HeadersTrait:: |
public | function | Current request status code response | |
HeadersTrait:: |
public | function | The name say its all | |
JavascriptTrait:: |
public | function | Evaluates a script and returns the result | |
JavascriptTrait:: |
public | function | Executes a script on the browser | |
JavascriptTrait:: |
public | function | Waits some time or until JS condition turns true. | |
KeyboardTrait:: |
public | function | Send a key-down event to the browser element | |
KeyboardTrait:: |
protected | function | Does some control and normalization for the key event modifier | |
KeyboardTrait:: |
public | function | ||
KeyboardTrait:: |
public | function | Pressed up specific keyboard key. | |
KeyboardTrait:: |
protected | function | Does some normalization for the char we want to do keyboard events with. | |
MouseTrait:: |
public | function | Clicks if possible on an element given by xpath | |
MouseTrait:: |
public | function | Double click on element found via xpath | |
MouseTrait:: |
public | function | Generates a mouseover event on the given element by xpath | |
MouseTrait:: |
public | function | Right click on element found via xpath | |
NavigationTrait:: |
public | function | Goes back if possible | |
NavigationTrait:: |
public | function | Goes forward if possible | |
NavigationTrait:: |
public | function | Gets the current url if any | |
NavigationTrait:: |
public | function | Reloads the page if possible | |
NavigationTrait:: |
public | function | Visits a given url | |
PageContentTrait:: |
public | function | ||
PageContentTrait:: |
public | function | Returns the inner html of a given xpath | |
PageContentTrait:: |
public | function | Gets the outer html of a given xpath | |
PageContentTrait:: |
public | function | Returns the binary representation of the current page we are in | |
PageContentTrait:: |
public | function | Given xpath, will try to get ALL the text, visible and not visible from such xpath | |
PhantomJSDriver:: |
public | function |
Upload a file to the browser Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Blur on element Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Drags one element to another Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Finds elements with specified XPath query. Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Focus on an element Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Gets the attribute value of a given element and name Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Gets the tag name of a given xpath Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Check if element given by xpath is visible or not Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Sets the basic auth user and password Overrides CoreDriver:: |
|
PhantomJSDriver:: |
public | function |
Puts the browser control inside the IFRAME
You own the control, make sure to go back to the parent calling this method with null Overrides CoreDriver:: |
|
SessionTrait:: |
protected | property | @var bool | |
SessionTrait:: |
public | function | Tells if the session is started or not | |
SessionTrait:: |
public | function | Clears the cookies in the browser, all of them | |
SessionTrait:: |
public | function | Starts a session to be used by the driver client | |
SessionTrait:: |
public | function | Stops the session completely, clean slate for the browser | |
WindowTrait:: |
public | function | Returns the current page window name | |
WindowTrait:: |
public | function | Return all the window handles currently present in phantomjs | |
WindowTrait:: |
public | function | Resizing a window with specified size | |
WindowTrait:: |
public | function | Switches to window by name if possible |