Laravel 浏览器测试断言

浏览器测试断言


assertTitle

断言页面标题匹配给定文本:

$browser->assertTitle($title);

assertTitleContains

断言页面标题包含给定文本:

$browser->assertTitleContains($title);

assertUrlIs

断言当前URL(不含查询字符串)匹配给定字符串:

$browser->assertUrlIs($url);

assertSchemeIs

断言当前 URL scheme 是否匹配给定 scheme:

$browser->assertSchemeIs($scheme);

assertSchemeIsNot

断言当前 URL scheme 是否不匹配给定 scheme:

$browser->assertSchemeIsNot($scheme);

assertHostIs

断言当前 URL host 是否匹配给定 host:

$browser->assertHostIs($host);

assertHostIsNot

断言当前 URL host 是否不匹配给定 host:

$browser->assertHostIsNot($host);

assertPortIs

断言当前 URL port 是否匹配给定 port:

$browser->assertPortIs($port);

assertPortIsNot

断言当前 URL port 是否不匹配给定 port:

$browser->assertPortIsNot($port);

assertPathBeginsWith

断言当前路径以给定路径开头:

$browser->assertPathBeginsWith($path);

assertPathIs

断言当前路径匹配给定路径:

$browser->assertPathIs('/home');

assertPathIsNot

断言当前路径不匹配给定路径:

$browser->assertPathIsNot('/home');

assertRouteIs

断言当前 URL 匹配给定命名路由 URL:

$browser->assertRouteIs($name, $parameters);

assertQueryStringHas

断言给定查询字符串参数存在:

$browser->assertQueryStringHas($name);

断言给定查询字符串存在并包含给定值:

$browser->assertQueryStringHas($name, $value);

assertQueryStringMissing

断言给定查询字符串参数缺失:

$browser->assertQueryStringMissing($name);

assertFragmentIs

断言当前片段是否与给定片段匹配:

$browser->assertFragmentIs('anchor');

assertFragmentBeginsWith

断言当前片段是否以给定片段开头:

$browser->assertFragmentBeginsWith('anchor');

assertFragmentIsNot

断言当前片段是否与给定片段不匹配:

$browser->assertFragmentIsNot('anchor');

assertHasCookie

断言给定 Cookie 存在:

$browser->assertHasCookie($name);

assertCookieMissing

断言给定 Cookie 不存在:

$browser->assertCookieMissing($name);

assertCookieValue

断言 Cookie 包含给定值:

$browser->assertCookieValue($name, $value);

assertPlainCookieValue

断言未加密 Cookie 包含给定值:

$browser->assertPlainCookieValue($name, $value);

assertSee

断言给定文本在页面存在:

$browser->assertSee($text);

assertDontSee

断言给定文本在页面不存在:

$browser->assertDontSee($text);

assertSeeIn

断言给定文本在指定选择器中存在:

$browser->assertSeeIn($selector, $text);

assertDontSeeIn

断言给定文本在指定选择器中不存在:

$browser->assertDontSeeIn($selector, $text);

assertSourceHas

断言给定源码在页面中存在:

$browser->assertSourceHas($code);

assertSourceMissing

断言给定源码在页面中不存在:

$browser->assertSourceMissing($code);

断言给定链接在页面中存在:

$browser->assertSeeLink($linkText);

断言给定链接在页面中不存在:

$browser->assertDontSeeLink($linkText);

assertInputValue

断言给定输入字段包含给定值:

$browser->assertInputValue($field, $value);

assertInputValueIsNot

断言给定输入字段不包含给定值:

$browser->assertInputValueIsNot($field, $value);

assertChecked

断言给定复选框被选中:

$browser->assertChecked($field);

assertNotChecked

断言给定复选框未被选中:

$browser->assertNotChecked($field);

assertRadioSelected

断言给定单选框被选中:

$browser->assertRadioSelected($field, $value);

assertRadioNotSelected

断言给定单选框未被选中:

$browser->assertRadioNotSelected($field, $value);

assertSelected

断言给定下拉框包含给定选择值:

$browser->assertSelected($field, $value);

assertNotSelected

断言给定下拉框不包含给定选择值:

$browser->assertNotSelected($field, $value);

assertSelectHasOptions

断言给定数值数组可以被选择:

$browser->assertSelectHasOptions($field, $values);

assertSelectMissingOptions

断言给定数值数组不能被选择:

$browser->assertSelectMissingOptions($field, $values);

assertSelectHasOption

断言给定数值可以被选择:

$browser->assertSelectHasOption($field, $value);

assertValue

断言匹配给定选择器的元素包含给定值:

$browser->assertValue($selector, $value);

assertAriaAttribute

断言给定选择器匹配的元素在提供的 aria 属性中包含给定值:

$browser->assertAriaAttribute($selector, $attribute, $value);

例如,给定标记 <button aria-label="Add"></>,我们可以像这样断言 aria-label 属性:

$browser->assertAriaAttribute('button', 'label', 'Add');

assertDataAttribute

断言给定选择器匹配的元素在提供的 data 属性中包含给定值:

$browser->assertDataAttribute($selector, $attribute, $value);

例如,给定标记 <tr id="row-1" data-content="attendees"></>,你可以像这样断言 data-label 属性:

$browser->assertDataAttribute('#row-1', 'content', 'attendees');

assertVisible

断言匹配给定选择器的元素可见:

$browser->assertVisible($selector);

assertPresent

断言匹配给定选择器的元素是否存在:

$browser->assertPresent($selector);

assertMissing

断言匹配给定选择器的元素不可见:

$browser->assertMissing($selector);

assertDialogOpened

断言带给定字符串的JavaScript对话框已打开:

$browser->assertDialogOpened($message);

assertEnabled

断言给定字段是否启用:

$browser->assertEnabled($field);

assertDisabled

断言给定字段是否禁用:

$browser->assertDisabled($field);

assertButtonEnabled

断言给定按钮是否启用:

$browser->assertButtonEnabled($button);

assertButtonDisabled

断言给定按钮是否禁用:

$browser->assertButtonDisabled($button);

assertFocused

断言给定字段是否获得焦点:

$browser->assertFocused($field);

assertNotFocused

断言给定字段是否失去焦点:

$browser->assertNotFocused($field);

assertVue

断言给定 Vue 组件数据与给定值匹配:

$browser->assertVue($property, $value, $componentSelector = null);

assertVueIsNot

断言给定 Vue 组件数据与给定值不匹配:

$browser->assertVueIsNot($property, $value, $componentSelector = null);

assertVueContains

断言给定 Vue 组件数据是否是一个数组并且包含给定值:

$browser->assertVueContains($property, $value, $componentSelector = null);

assertVueDoesNotContain

断言给定 Vue 组件数据是否是一个数组并且不包含给定值:

$browser->assertVueDoesNotContain($property, $value, $componentSelector = null);

查看笔记

扫码一下
查看教程更方便