WebElement
class WebElement implements IWebElement, INodeElementAware (View source)
Regular element on a page, that is initialized using Selenium-style selector.
Properties
private NodeElement | $_wrappedElement | Wrapped element. | |
private IPageFactory | $_pageFactory | Stores instance of used page factory. | |
private Escaper | $_xpathEscaper | The XPath escaper. |
Methods
Creates Element instance based on existing NodeElement instance.
Finds first element with specified selector.
Finds all elements with specified selector.
Waits for an element(-s) to appear and returns it.
Proxies all methods to sub-object.
Returns the XPath escaper.
Returns page factory, used during object creation.
Returns string representation of element.
No description
Returns XPath for handled element.
Returns parent element to the current one.
Returns current node tag name.
Returns the value of the form field or option element.
Sets the value of the form field.
Checks whether element has attribute with specified name.
Returns specified attribute value.
Checks whether an element has a named CSS class.
Clicks current node.
Presses current button.
Double-clicks current node.
Right-clicks current node.
Checks current node if it's a checkbox field.
Unchecks current node if it's a checkbox field.
Checks whether current node is checked if it's a checkbox or radio field.
Selects specified option for select field or specified radio button in the group.
Checks whether current node is selected if it's a option field.
Attach file to current node if it's a file input.
Checks whether current node is visible on page.
Simulates a mouse over on the element.
Drags current node onto other node.
Brings focus to element.
Removes focus from element.
Presses specific keyboard key.
Pressed down specific keyboard key.
Pressed up specific keyboard key.
Submits the form.
Finds element by its id.
Checks whether element has a link with specified locator.
Finds link with specified locator.
Clicks link with specified locator.
Checks whether element has a button (input[type=submit|image|button|reset], button) with specified locator.
Finds button (input[type=submit|image|button|reset], button) with specified locator.
Presses button (input[type=submit|image|button|reset], button) with specified locator.
Checks whether element has a field (input, textarea, select) with specified locator.
Finds field (input, textarea, select) with specified locator.
Fills in field (input, textarea, select) with specified locator.
Checks whether element has a checkbox with specified locator, which is checked.
Checks whether element has a checkbox with specified locator, which is unchecked.
Checks checkbox with specified locator.
Unchecks checkbox with specified locator.
Checks whether element has a select field with specified locator.
Selects option from select field with specified locator.
Checks whether element has a table with specified locator.
Attach file to file field with specified locator.
Checks whether element with specified selector exists inside the current element.
Checks if an element still exists in the DOM.
Returns element text (inside tag).
Returns element inner html.
Returns element outer html.
Details
at line 109
__construct(NodeElement $wrapped_element, IPageFactory $page_factory)
Initializes web element.
at line 124
static INodeElementAware
fromNodeElement(NodeElement $node_element, IPageFactory $page_factory)
Creates Element instance based on existing NodeElement instance.
at line 137
NodeElement|null
find(string $selector, string|array $locator)
Finds first element with specified selector.
at line 150
NodeElement[]
findAll(string $selector, string|array $locator)
Finds all elements with specified selector.
at line 164
mixed
waitFor(integer $timeout, callable $callback)
Waits for an element(-s) to appear and returns it.
at line 178
mixed
__call(string $method, array $arguments)
Proxies all methods to sub-object.
at line 194
Escaper
getXpathEscaper()
Returns the XPath escaper.
at line 205
Session
getSession()
deprecated
deprecated
Returns element session.
at line 220
protected IPageFactory
getPageFactory()
Returns page factory, used during object creation.
at line 230
string
__toString()
Returns string representation of element.
at line 79
Expectation
shouldReceive(string $name)
at line 79
string
getXpath()
Returns XPath for handled element.
at line 79
NodeElement
getParent()
Returns parent element to the current one.
at line 79
string
getTagName()
Returns current node tag name.
at line 79
string|boolean|array
getValue()
Returns the value of the form field or option element.
at line 79
void
setValue($value)
Sets the value of the form field.
at line 79
boolean
hasAttribute($name)
Checks whether element has attribute with specified name.
at line 79
string|null
getAttribute($name)
Returns specified attribute value.
at line 79
boolean
hasClass($className)
Checks whether an element has a named CSS class.
at line 79
void
click()
Clicks current node.
at line 79
void
press()
Presses current button.
at line 79
void
doubleClick()
Double-clicks current node.
at line 79
void
rightClick()
Right-clicks current node.
at line 79
void
check()
Checks current node if it's a checkbox field.
at line 79
void
uncheck()
Unchecks current node if it's a checkbox field.
at line 79
boolean
isChecked()
Checks whether current node is checked if it's a checkbox or radio field.
at line 79
void
selectOption($option, $multiple = false)
Selects specified option for select field or specified radio button in the group.
at line 79
boolean
isSelected()
Checks whether current node is selected if it's a option field.
at line 79
void
attachFile($path)
Attach file to current node if it's a file input.
at line 79
boolean
isVisible()
Checks whether current node is visible on page.
at line 79
void
mouseOver()
Simulates a mouse over on the element.
at line 79
void
dragTo(ElementInterface $destination)
Drags current node onto other node.
at line 79
void
focus()
Brings focus to element.
at line 79
void
blur()
Removes focus from element.
at line 79
void
keyPress($char, $modifier = null)
Presses specific keyboard key.
at line 79
void
keyDown($char, $modifier = null)
Pressed down specific keyboard key.
at line 79
void
keyUp($char, $modifier = null)
Pressed up specific keyboard key.
at line 79
void
submit()
Submits the form.
at line 79
NodeElement|null
findById($id)
Finds element by its id.
at line 79
boolean
hasLink($locator)
Checks whether element has a link with specified locator.
at line 79
NodeElement|null
findLink($locator)
Finds link with specified locator.
at line 79
void
clickLink($locator)
Clicks link with specified locator.
at line 79
boolean
hasButton($locator)
Checks whether element has a button (input[type=submit|image|button|reset], button) with specified locator.
at line 79
NodeElement|null
findButton($locator)
Finds button (input[type=submit|image|button|reset], button) with specified locator.
at line 79
void
pressButton($locator)
Presses button (input[type=submit|image|button|reset], button) with specified locator.
at line 79
boolean
hasField($locator)
Checks whether element has a field (input, textarea, select) with specified locator.
at line 79
NodeElement|null
findField($locator)
Finds field (input, textarea, select) with specified locator.
at line 79
void
fillField($locator, $value)
Fills in field (input, textarea, select) with specified locator.
at line 79
boolean
hasCheckedField($locator)
Checks whether element has a checkbox with specified locator, which is checked.
at line 79
boolean
hasUncheckedField($locator)
Checks whether element has a checkbox with specified locator, which is unchecked.
at line 79
void
checkField($locator)
Checks checkbox with specified locator.
at line 79
void
uncheckField($locator)
Unchecks checkbox with specified locator.
at line 79
boolean
hasSelect($locator)
Checks whether element has a select field with specified locator.
at line 79
void
selectFieldOption($locator, $value, $multiple = false)
Selects option from select field with specified locator.
at line 79
boolean
hasTable($locator)
Checks whether element has a table with specified locator.
at line 79
void
attachFileToField($locator, $path)
Attach file to file field with specified locator.
at line 79
boolean
has($selector, $locator)
Checks whether element with specified selector exists inside the current element.
at line 79
boolean
isValid()
Checks if an element still exists in the DOM.
at line 79
string
getText()
Returns element text (inside tag).
at line 79
string
getHtml()
Returns element inner html.
at line 79
string
getOuterHtml()
Returns element outer html.