When filling out forms you probably want to use the generators.
$el['.t-field_first_name']->setValue($this->generate('name:first'));
Generators |
---|
email () |
integer ($min, $max) |
name ($length = 5) |
password ($length = 32) |
phone () |
sentence ($wordcount = 5) |
title ($wordcount = 5) |
url () |
username ($length = 10) |
words ($wordcount = 5) |
CKEditorTrait |
---|
setCkEditorValue (string $css_selector, $value) |
InteractiveTrait |
---|
assertPreConditions () |
TimeTrait |
---|
setTimeValue ($css_selector, $time) |
EndToEndTestCase |
---|
assert ($fail_message = '') |
assertElementExists ($css_selector, $failure_message = '') |
assertElementNotExists ($css_selector, $failure_message = '') |
assertElementNotVisible ($css_selector, $failure_message = '') |
assertElementVisible ($css_selector, $failure_message = '') |
assertManual ($assertions, array $prerequisite_steps = Array) |
assertUrlContentTypeEquals ($content_type, $url) |
assertUrlNotSame ($expected) |
assertUrlRedirectsTo ($final_url, $url) |
assertUrlSame ($expected) |
assertUrlStatusCodeEquals ($status_code, $url, $message = '') |
assertUrlStatusCodeNotEquals ($status_code, $url) |
attachObservationCss ($css) |
beginObservation ($button_title = '', array $button_css_classes = Array) |
debugger () |
doCssInjection () |
el ($css_selector, $limit_to_one = true) |
els ($css_selector) |
emptyCookieJar () |
endObservation () |
ensureWebSessionStarted () |
generate ($method) |
getClient (array $options = Array) |
getCookieJar () |
getDomElements (array $css_selectors) |
getEmailHandler () |
getIdFromCurrentUrl () |
getJavascriptSelectorCode ($css_selector) |
getManualAssertUICssStyles () |
getMatchedFromCurrentUrl (string $regex) |
getObserverUiCssStyles () |
getPopupCssStyles () |
getSession () |
getStored ($key, $default = NULL) |
handleBaseUrl () |
injectCss ($css) |
injectObserverAnchors () |
injectObserverUiIntoDom ($css_selector, $position, $button_title, $short_message = '', array $button_classes = Array) |
loadPageByUrl ($url) |
onAfterLastTest () |
onBeforeFirstTest () |
requestThenAssert (callable $callback, $url, array $client_options = Array, $method = 'HEAD', callable or NULL $on_fail = NULL) |
requireElement ($css_selector) |
resolveUrl ($url, $remove_authentication_credentials = false) |
scrollToElementTop ($css_selector, $offset = 20) |
scrollTop () |
setEmailHandler (AKlump\DrupalTest\Utilities\EmailHandlerInterface $handler) |
store ($key, $value) |
wait ($seconds) |
waitFor (callable $test, $description = NULL, $timeout = NULL) |
waitForElement ($css_selector, $timeout = NULL) |
waitForElementNotVisible ($css_selector, $timeout = NULL) |
waitForElementVisible ($css_selector, $timeout = NULL) |
waitForEmail ($expected_count = 1, $timeout = NULL) |
waitForFinished () |
waitForObserver ($display_object = NULL) |
waitForObserverPopup (AKlump\DrupalTest\Utilities\Popup $popup) |
waitForPageContains ($substring, $timeout = NULL) |
There is some overlap in assertions between methods of
ClientTestCase
and methods on Mink'sWebAssert
class, but the former always uses css selectors, so it's a little less verbose.
DocumentElement
objectsLearn more here.
DocumentElement |
---|
attachFileToField ($locator, $path) |
checkField ($locator) |
clickLink ($locator) |
elementNotFound ($type, $selector = NULL, $locator = NULL) |
fillField ($locator, $value) |
find ($selector, $locator) |
findAll ($selector, $locator) |
findButton ($locator) |
findById ($id) |
findField ($locator) |
findLink ($locator) |
getContent () |
getDriver () |
getHtml () |
getOuterHtml () |
getSelectorsHandler () |
getSession () |
getText () |
getXpath () |
has ($selector, $locator) |
hasButton ($locator) |
hasCheckedField ($locator) |
hasContent ($content) |
hasField ($locator) |
hasLink ($locator) |
hasSelect ($locator) |
hasTable ($locator) |
hasUncheckedField ($locator) |
isValid () |
pressButton ($locator) |
selectFieldOption ($locator, $value, $multiple = false) |
uncheckField ($locator) |
waitFor ($timeout, $callback) |
NodeElement
objectsLearn more here.
<?php
class Test {
public function testExample() {
// By using getDomElements we ensure only one of .t-link.
$el = $this->loadPageByUrl('/node/9750')
->getDomElements([
'.t-link',
]);
// $el['.t-link'] is an instance of NodeElement.
$el['.t-link']->click();
// Altenatively you could do this.
$this->el('.t-link')->click()
}
}
NodeElement |
---|
attachFile ($path) |
attachFileToField ($locator, $path) |
blur () |
check () |
checkField ($locator) |
click () |
clickLink ($locator) |
doubleClick () |
dragTo (Behat\Mink\Element\ElementInterface $destination) |
elementNotFound ($type, $selector = NULL, $locator = NULL) |
fillField ($locator, $value) |
find ($selector, $locator) |
findAll ($selector, $locator) |
findButton ($locator) |
findById ($id) |
findField ($locator) |
findLink ($locator) |
focus () |
getAttribute ($name) |
getDriver () |
getHtml () |
getOuterHtml () |
getParent () |
getSelectorsHandler () |
getSession () |
getTagName () |
getText () |
getValue () |
getXpath () |
has ($selector, $locator) |
hasAttribute ($name) |
hasButton ($locator) |
hasCheckedField ($locator) |
hasClass ($className) |
hasField ($locator) |
hasLink ($locator) |
hasSelect ($locator) |
hasTable ($locator) |
hasUncheckedField ($locator) |
isChecked () |
isSelected () |
isValid () |
isVisible () |
keyDown ($char, $modifier = NULL) |
keyPress ($char, $modifier = NULL) |
keyUp ($char, $modifier = NULL) |
mouseOver () |
press () |
pressButton ($locator) |
rightClick () |
selectFieldOption ($locator, $value, $multiple = false) |
selectOption ($option, $multiple = false) |
setValue ($value) |
submit () |
uncheck () |
uncheckField ($locator) |
waitFor ($timeout, $callback) |
Load a page and then make assertions using Mink's WebAssert class.
<?php
class Test {
public function testExample() {
$this->loadPageByUrl('/node/9750')
->assert()
->elementTextContains('css', '#button', 'English');
$this->assert()
->elementTextContains('css', '#button-2', 'Spanish');
}
}
WebAssert |
---|
addressEquals ($page) |
addressMatches ($regex) |
addressNotEquals ($page) |
assert ($condition, $message) |
assertElement ($condition, $message, Behat\Mink\Element\Element $element) |
assertElementText ($condition, $message, Behat\Mink\Element\Element $element) |
assertResponseText ($condition, $message) |
checkboxChecked ($field, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
checkboxNotChecked ($field, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
cleanUrl ($url) |
cookieEquals ($name, $value) |
cookieExists ($name) |
elementAttributeContains ($selectorType, $selector, $attribute, $text) |
elementAttributeExists ($selectorType, $selector, $attribute) |
elementAttributeNotContains ($selectorType, $selector, $attribute, $text) |
elementContains ($selectorType, $selector, $html) |
elementExists ($selectorType, $selector, Behat\Mink\Element\ElementInterface or NULL $container = NULL) |
elementNotContains ($selectorType, $selector, $html) |
elementNotExists ($selectorType, $selector, Behat\Mink\Element\ElementInterface or NULL $container = NULL) |
elementsCount ($selectorType, $selector, $count, Behat\Mink\Element\ElementInterface or NULL $container = NULL) |
elementTextContains ($selectorType, $selector, $text) |
elementTextNotContains ($selectorType, $selector, $text) |
fieldExists ($field, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
fieldNotExists ($field, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
fieldValueEquals ($field, $value, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
fieldValueNotEquals ($field, $value, Behat\Mink\Element\TraversableElement or NULL $container = NULL) |
getCurrentUrlPath () |
getMatchingElementRepresentation ($selectorType, $selector, $plural = false) |
pageTextContains ($text) |
pageTextMatches ($regex) |
pageTextNotContains ($text) |
pageTextNotMatches ($regex) |
responseContains ($text) |
responseHeaderContains ($name, $value) |
responseHeaderEquals ($name, $value) |
responseHeaderMatches ($name, $regex) |
responseHeaderNotContains ($name, $value) |
responseHeaderNotEquals ($name, $value) |
responseHeaderNotMatches ($name, $regex) |
responseMatches ($regex) |
responseNotContains ($text) |
responseNotMatches ($regex) |
statusCodeEquals ($code) |
statusCodeNotEquals ($code) |
Balloon |
---|
__construct (string $message) |
after () |
before () |
create ($message) |
delay (integer $seconds) |
dispatch (string $callback_name) |
el (string $css_selector) |
getBody () |
getCssSelector ($default = '') |
getOffset () |
getPosition ($default = '') |
getTitle () |
offset (integer $x, integer $y) |
onAfterShow (callable $callback) |
onBeforeShow (callable $callback) |
Url |
---|
__construct ($url) |
toString () |