WebGuy.php 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008
  1. <?php
  2. // This class was automatically generated by build task
  3. // You should not change it manually as it will be overwritten on next build
  4. // @codingStandardsIgnoreFile
  5. use \Codeception\Maybe;
  6. use Codeception\Module\PhpBrowser;
  7. use Codeception\Module\WebHelper;
  8. /**
  9. * Inherited methods
  10. * @method void execute($callable)
  11. * @method void wantToTest($text)
  12. * @method void wantTo($text)
  13. * @method void expectTo($prediction)
  14. * @method void expect($prediction)
  15. * @method void amGoingTo($argumentation)
  16. * @method void am($role)
  17. * @method void lookForwardTo($achieveValue)
  18. * @method void offsetGet($offset)
  19. * @method void offsetSet($offset, $value)
  20. * @method void offsetExists($offset)
  21. * @method void offsetUnset($offset)
  22. */
  23. class WebGuy extends \Codeception\AbstractGuy
  24. {
  25. /**
  26. * This method is generated.
  27. * Documentation taken from corresponding module.
  28. * ----------------------------------------------
  29. *
  30. * Submits a form located on page.
  31. * Specify the form by it's css or xpath selector.
  32. * Fill the form fields values as array.
  33. *
  34. * Skipped fields will be filled by their values from page.
  35. * You don't need to click the 'Submit' button afterwards.
  36. * This command itself triggers the request to form's action.
  37. *
  38. * Examples:
  39. *
  40. * ``` php
  41. * <?php
  42. * $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'));
  43. *
  44. * ```
  45. *
  46. * For sample Sign Up form:
  47. *
  48. * ``` html
  49. * <form action="/sign_up">
  50. * Login: <input type="text" name="user[login]" /><br/>
  51. * Password: <input type="password" name="user[password]" /><br/>
  52. * Do you agree to out terms? <input type="checkbox" name="user[agree]" /><br/>
  53. * Select pricing plan <select name="plan"><option value="1">Free</option><option value="2" selected="selected">Paid</option></select>
  54. * <input type="submit" value="Submit" />
  55. * </form>
  56. * ```
  57. * I can write this:
  58. *
  59. * ``` php
  60. * <?php
  61. * $I->submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)));
  62. *
  63. * ```
  64. * Note, that pricing plan will be set to Paid, as it's selected on page.
  65. *
  66. * @param $selector
  67. * @param $params
  68. * @see Codeception\Module\PhpBrowser::submitForm()
  69. * @return \Codeception\Maybe
  70. */
  71. public function submitForm($selector, $params) {
  72. $this->scenario->addStep(new \Codeception\Step\Action('submitForm', func_get_args()));
  73. if ($this->scenario->running()) {
  74. $result = $this->scenario->runStep();
  75. return new Maybe($result);
  76. }
  77. return new Maybe();
  78. }
  79. /**
  80. * This method is generated.
  81. * Documentation taken from corresponding module.
  82. * ----------------------------------------------
  83. *
  84. * If your page triggers an ajax request, you can perform it manually.
  85. * This action sends a POST ajax request with specified params.
  86. * Additional params can be passed as array.
  87. *
  88. * Example:
  89. *
  90. * Imagine that by clicking checkbox you trigger ajax request which updates user settings.
  91. * We emulate that click by running this ajax request manually.
  92. *
  93. * ``` php
  94. * <?php
  95. * $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true); // POST
  96. * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true); // GET
  97. *
  98. * ```
  99. *
  100. * @param $uri
  101. * @param $params
  102. * @see Codeception\Module\PhpBrowser::sendAjaxPostRequest()
  103. * @return \Codeception\Maybe
  104. */
  105. public function sendAjaxPostRequest($uri, $params = null) {
  106. $this->scenario->addStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args()));
  107. if ($this->scenario->running()) {
  108. $result = $this->scenario->runStep();
  109. return new Maybe($result);
  110. }
  111. return new Maybe();
  112. }
  113. /**
  114. * This method is generated.
  115. * Documentation taken from corresponding module.
  116. * ----------------------------------------------
  117. *
  118. * If your page triggers an ajax request, you can perform it manually.
  119. * This action sends a GET ajax request with specified params.
  120. *
  121. * See ->sendAjaxPostRequest for examples.
  122. *
  123. * @param $uri
  124. * @param $params
  125. * @see Codeception\Module\PhpBrowser::sendAjaxGetRequest()
  126. * @return \Codeception\Maybe
  127. */
  128. public function sendAjaxGetRequest($uri, $params = null) {
  129. $this->scenario->addStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args()));
  130. if ($this->scenario->running()) {
  131. $result = $this->scenario->runStep();
  132. return new Maybe($result);
  133. }
  134. return new Maybe();
  135. }
  136. /**
  137. * This method is generated.
  138. * Documentation taken from corresponding module.
  139. * ----------------------------------------------
  140. *
  141. * Asserts that current page has 404 response status code.
  142. * Conditional Assertion: Test won't be stopped on fail
  143. * @see Codeception\Module\PhpBrowser::seePageNotFound()
  144. * @return \Codeception\Maybe
  145. */
  146. public function canSeePageNotFound() {
  147. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args()));
  148. if ($this->scenario->running()) {
  149. $result = $this->scenario->runStep();
  150. return new Maybe($result);
  151. }
  152. return new Maybe();
  153. }
  154. /**
  155. * This method is generated.
  156. * Documentation taken from corresponding module.
  157. * ----------------------------------------------
  158. *
  159. * Asserts that current page has 404 response status code.
  160. * @see Codeception\Module\PhpBrowser::seePageNotFound()
  161. * @return \Codeception\Maybe
  162. */
  163. public function seePageNotFound() {
  164. $this->scenario->addStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args()));
  165. if ($this->scenario->running()) {
  166. $result = $this->scenario->runStep();
  167. return new Maybe($result);
  168. }
  169. return new Maybe();
  170. }
  171. /**
  172. * This method is generated.
  173. * Documentation taken from corresponding module.
  174. * ----------------------------------------------
  175. *
  176. * Checks that response code is equal to value provided.
  177. *
  178. * @param $code
  179. * @return mixed
  180. * Conditional Assertion: Test won't be stopped on fail
  181. * @see Codeception\Module\PhpBrowser::seeResponseCodeIs()
  182. * @return \Codeception\Maybe
  183. */
  184. public function canSeeResponseCodeIs($code) {
  185. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args()));
  186. if ($this->scenario->running()) {
  187. $result = $this->scenario->runStep();
  188. return new Maybe($result);
  189. }
  190. return new Maybe();
  191. }
  192. /**
  193. * This method is generated.
  194. * Documentation taken from corresponding module.
  195. * ----------------------------------------------
  196. *
  197. * Checks that response code is equal to value provided.
  198. *
  199. * @param $code
  200. * @return mixed
  201. * @see Codeception\Module\PhpBrowser::seeResponseCodeIs()
  202. * @return \Codeception\Maybe
  203. */
  204. public function seeResponseCodeIs($code) {
  205. $this->scenario->addStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args()));
  206. if ($this->scenario->running()) {
  207. $result = $this->scenario->runStep();
  208. return new Maybe($result);
  209. }
  210. return new Maybe();
  211. }
  212. /**
  213. * This method is generated.
  214. * Documentation taken from corresponding module.
  215. * ----------------------------------------------
  216. *
  217. * Adds HTTP authentication via username/password.
  218. *
  219. * @param $username
  220. * @param $password
  221. * @see Codeception\Module\PhpBrowser::amHttpAuthenticated()
  222. * @return \Codeception\Maybe
  223. */
  224. public function amHttpAuthenticated($username, $password) {
  225. $this->scenario->addStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args()));
  226. if ($this->scenario->running()) {
  227. $result = $this->scenario->runStep();
  228. return new Maybe($result);
  229. }
  230. return new Maybe();
  231. }
  232. /**
  233. * This method is generated.
  234. * Documentation taken from corresponding module.
  235. * ----------------------------------------------
  236. *
  237. * Low-level API method.
  238. * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly
  239. *
  240. * Example:
  241. *
  242. * ``` php
  243. * <?php
  244. * // from the official Guzzle manual
  245. * $I->amGoingTo('Sign all requests with OAuth');
  246. * $I->executeInGuzzle(function (\Guzzle\Http\Client $client) {
  247. * $client->addSubscriber(new Guzzle\Plugin\Oauth\OauthPlugin(array(
  248. * 'consumer_key' => '***',
  249. * 'consumer_secret' => '***',
  250. * 'token' => '***',
  251. * 'token_secret' => '***'
  252. * )));
  253. * });
  254. * ?>
  255. * ```
  256. *
  257. * Not recommended this command too be used on regular basis.
  258. * If Codeception lacks important Guzzle Client methods implement then and submit patches.
  259. *
  260. * @param callable $function
  261. * @see Codeception\Module\PhpBrowser::executeInGuzzle()
  262. * @return \Codeception\Maybe
  263. */
  264. public function executeInGuzzle($function) {
  265. $this->scenario->addStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args()));
  266. if ($this->scenario->running()) {
  267. $result = $this->scenario->runStep();
  268. return new Maybe($result);
  269. }
  270. return new Maybe();
  271. }
  272. /**
  273. * This method is generated.
  274. * Documentation taken from corresponding module.
  275. * ----------------------------------------------
  276. *
  277. * Assert if the specified checkbox is checked.
  278. * Use css selector or xpath to match.
  279. *
  280. * Example:
  281. *
  282. * ``` php
  283. * <?php
  284. * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
  285. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
  286. * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
  287. * ?>
  288. * ```
  289. *
  290. * @param $checkbox
  291. * Conditional Assertion: Test won't be stopped on fail
  292. * @see Codeception\Module\PhpBrowser::seeCheckboxIsChecked()
  293. * @return \Codeception\Maybe
  294. */
  295. public function canSeeCheckboxIsChecked($checkbox) {
  296. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
  297. if ($this->scenario->running()) {
  298. $result = $this->scenario->runStep();
  299. return new Maybe($result);
  300. }
  301. return new Maybe();
  302. }
  303. /**
  304. * This method is generated.
  305. * Documentation taken from corresponding module.
  306. * ----------------------------------------------
  307. *
  308. * Assert if the specified checkbox is checked.
  309. * Use css selector or xpath to match.
  310. *
  311. * Example:
  312. *
  313. * ``` php
  314. * <?php
  315. * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
  316. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
  317. * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
  318. * ?>
  319. * ```
  320. *
  321. * @param $checkbox
  322. * @see Codeception\Module\PhpBrowser::seeCheckboxIsChecked()
  323. * @return \Codeception\Maybe
  324. */
  325. public function seeCheckboxIsChecked($checkbox) {
  326. $this->scenario->addStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
  327. if ($this->scenario->running()) {
  328. $result = $this->scenario->runStep();
  329. return new Maybe($result);
  330. }
  331. return new Maybe();
  332. }
  333. /**
  334. * This method is generated.
  335. * Documentation taken from corresponding module.
  336. * ----------------------------------------------
  337. *
  338. * Assert if the specified checkbox is unchecked.
  339. * Use css selector or xpath to match.
  340. *
  341. * Example:
  342. *
  343. * ``` php
  344. * <?php
  345. * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
  346. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
  347. * ?>
  348. * ```
  349. *
  350. * @param $checkbox
  351. * Conditional Assertion: Test won't be stopped on fail
  352. * @see Codeception\Module\PhpBrowser::dontSeeCheckboxIsChecked()
  353. * @return \Codeception\Maybe
  354. */
  355. public function cantSeeCheckboxIsChecked($checkbox) {
  356. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
  357. if ($this->scenario->running()) {
  358. $result = $this->scenario->runStep();
  359. return new Maybe($result);
  360. }
  361. return new Maybe();
  362. }
  363. /**
  364. * This method is generated.
  365. * Documentation taken from corresponding module.
  366. * ----------------------------------------------
  367. *
  368. * Assert if the specified checkbox is unchecked.
  369. * Use css selector or xpath to match.
  370. *
  371. * Example:
  372. *
  373. * ``` php
  374. * <?php
  375. * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
  376. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
  377. * ?>
  378. * ```
  379. *
  380. * @param $checkbox
  381. * @see Codeception\Module\PhpBrowser::dontSeeCheckboxIsChecked()
  382. * @return \Codeception\Maybe
  383. */
  384. public function dontSeeCheckboxIsChecked($checkbox) {
  385. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args()));
  386. if ($this->scenario->running()) {
  387. $result = $this->scenario->runStep();
  388. return new Maybe($result);
  389. }
  390. return new Maybe();
  391. }
  392. /**
  393. * This method is generated.
  394. * Documentation taken from corresponding module.
  395. * ----------------------------------------------
  396. *
  397. * Opens the page.
  398. *
  399. * @param $page
  400. * @see Codeception\Util\Mink::amOnPage()
  401. * @return \Codeception\Maybe
  402. */
  403. public function amOnPage($page) {
  404. $this->scenario->addStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
  405. if ($this->scenario->running()) {
  406. $result = $this->scenario->runStep();
  407. return new Maybe($result);
  408. }
  409. return new Maybe();
  410. }
  411. /**
  412. * This method is generated.
  413. * Documentation taken from corresponding module.
  414. * ----------------------------------------------
  415. *
  416. * Sets 'url' configuration parameter to hosts subdomain.
  417. * It does not open a page on subdomain. Use `amOnPage` for that
  418. *
  419. * ``` php
  420. * <?php
  421. * // If config is: 'http://mysite.com'
  422. * // or config is: 'http://www.mysite.com'
  423. * // or config is: 'http://company.mysite.com'
  424. *
  425. * $I->amOnSubdomain('user');
  426. * $I->amOnPage('/');
  427. * // moves to http://user.mysite.com/
  428. * ?>
  429. * ```
  430. * @param $subdomain
  431. * @return mixed
  432. * @see Codeception\Util\Mink::amOnSubdomain()
  433. * @return \Codeception\Maybe
  434. */
  435. public function amOnSubdomain($subdomain) {
  436. $this->scenario->addStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args()));
  437. if ($this->scenario->running()) {
  438. $result = $this->scenario->runStep();
  439. return new Maybe($result);
  440. }
  441. return new Maybe();
  442. }
  443. /**
  444. * This method is generated.
  445. * Documentation taken from corresponding module.
  446. * ----------------------------------------------
  447. *
  448. * @param string $text
  449. * @param string $selector
  450. *
  451. * @return void
  452. * Conditional Assertion: Test won't be stopped on fail
  453. * @see Codeception\Util\Mink::dontSee()
  454. * @return \Codeception\Maybe
  455. */
  456. public function cantSee($text, $selector = null) {
  457. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
  458. if ($this->scenario->running()) {
  459. $result = $this->scenario->runStep();
  460. return new Maybe($result);
  461. }
  462. return new Maybe();
  463. }
  464. /**
  465. * This method is generated.
  466. * Documentation taken from corresponding module.
  467. * ----------------------------------------------
  468. *
  469. * @param string $text
  470. * @param string $selector
  471. *
  472. * @return void
  473. * @see Codeception\Util\Mink::dontSee()
  474. * @return \Codeception\Maybe
  475. */
  476. public function dontSee($text, $selector = null) {
  477. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSee', func_get_args()));
  478. if ($this->scenario->running()) {
  479. $result = $this->scenario->runStep();
  480. return new Maybe($result);
  481. }
  482. return new Maybe();
  483. }
  484. /**
  485. * This method is generated.
  486. * Documentation taken from corresponding module.
  487. * ----------------------------------------------
  488. *
  489. * Check if current page contains the text specified.
  490. * Specify the css selector to match only specific region.
  491. *
  492. * Examples:
  493. *
  494. * ``` php
  495. * <?php
  496. * $I->see('Logout'); // I can suppose user is logged in
  497. * $I->see('Sign Up','h1'); // I can suppose it's a signup page
  498. * $I->see('Sign Up','//body/h1'); // with XPath
  499. * ?>
  500. * ```
  501. *
  502. * @param $text
  503. * @param null $selector
  504. * Conditional Assertion: Test won't be stopped on fail
  505. * @see Codeception\Util\Mink::see()
  506. * @return \Codeception\Maybe
  507. */
  508. public function canSee($text, $selector = null) {
  509. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
  510. if ($this->scenario->running()) {
  511. $result = $this->scenario->runStep();
  512. return new Maybe($result);
  513. }
  514. return new Maybe();
  515. }
  516. /**
  517. * This method is generated.
  518. * Documentation taken from corresponding module.
  519. * ----------------------------------------------
  520. *
  521. * Check if current page contains the text specified.
  522. * Specify the css selector to match only specific region.
  523. *
  524. * Examples:
  525. *
  526. * ``` php
  527. * <?php
  528. * $I->see('Logout'); // I can suppose user is logged in
  529. * $I->see('Sign Up','h1'); // I can suppose it's a signup page
  530. * $I->see('Sign Up','//body/h1'); // with XPath
  531. * ?>
  532. * ```
  533. *
  534. * @param $text
  535. * @param null $selector
  536. * @see Codeception\Util\Mink::see()
  537. * @return \Codeception\Maybe
  538. */
  539. public function see($text, $selector = null) {
  540. $this->scenario->addStep(new \Codeception\Step\Assertion('see', func_get_args()));
  541. if ($this->scenario->running()) {
  542. $result = $this->scenario->runStep();
  543. return new Maybe($result);
  544. }
  545. return new Maybe();
  546. }
  547. /**
  548. * This method is generated.
  549. * Documentation taken from corresponding module.
  550. * ----------------------------------------------
  551. *
  552. * Checks if there is a link with text specified.
  553. * Specify url to match link with exact this url.
  554. *
  555. * Examples:
  556. *
  557. * ``` php
  558. * <?php
  559. * $I->seeLink('Logout'); // matches <a href="#">Logout</a>
  560. * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
  561. * ?>
  562. * ```
  563. *
  564. * @param $text
  565. * @param null $url
  566. * Conditional Assertion: Test won't be stopped on fail
  567. * @see Codeception\Util\Mink::seeLink()
  568. * @return \Codeception\Maybe
  569. */
  570. public function canSeeLink($text, $url = null) {
  571. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
  572. if ($this->scenario->running()) {
  573. $result = $this->scenario->runStep();
  574. return new Maybe($result);
  575. }
  576. return new Maybe();
  577. }
  578. /**
  579. * This method is generated.
  580. * Documentation taken from corresponding module.
  581. * ----------------------------------------------
  582. *
  583. * Checks if there is a link with text specified.
  584. * Specify url to match link with exact this url.
  585. *
  586. * Examples:
  587. *
  588. * ``` php
  589. * <?php
  590. * $I->seeLink('Logout'); // matches <a href="#">Logout</a>
  591. * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
  592. * ?>
  593. * ```
  594. *
  595. * @param $text
  596. * @param null $url
  597. * @see Codeception\Util\Mink::seeLink()
  598. * @return \Codeception\Maybe
  599. */
  600. public function seeLink($text, $url = null) {
  601. $this->scenario->addStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
  602. if ($this->scenario->running()) {
  603. $result = $this->scenario->runStep();
  604. return new Maybe($result);
  605. }
  606. return new Maybe();
  607. }
  608. /**
  609. * This method is generated.
  610. * Documentation taken from corresponding module.
  611. * ----------------------------------------------
  612. *
  613. * Checks if page doesn't contain the link with text specified.
  614. * Specify url to narrow the results.
  615. *
  616. * Examples:
  617. *
  618. * ``` php
  619. * <?php
  620. * $I->dontSeeLink('Logout'); // I suppose user is not logged in
  621. * ?>
  622. * ```
  623. *
  624. * @param $text
  625. * @param null $url
  626. * Conditional Assertion: Test won't be stopped on fail
  627. * @see Codeception\Util\Mink::dontSeeLink()
  628. * @return \Codeception\Maybe
  629. */
  630. public function cantSeeLink($text, $url = null) {
  631. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
  632. if ($this->scenario->running()) {
  633. $result = $this->scenario->runStep();
  634. return new Maybe($result);
  635. }
  636. return new Maybe();
  637. }
  638. /**
  639. * This method is generated.
  640. * Documentation taken from corresponding module.
  641. * ----------------------------------------------
  642. *
  643. * Checks if page doesn't contain the link with text specified.
  644. * Specify url to narrow the results.
  645. *
  646. * Examples:
  647. *
  648. * ``` php
  649. * <?php
  650. * $I->dontSeeLink('Logout'); // I suppose user is not logged in
  651. * ?>
  652. * ```
  653. *
  654. * @param $text
  655. * @param null $url
  656. * @see Codeception\Util\Mink::dontSeeLink()
  657. * @return \Codeception\Maybe
  658. */
  659. public function dontSeeLink($text, $url = null) {
  660. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args()));
  661. if ($this->scenario->running()) {
  662. $result = $this->scenario->runStep();
  663. return new Maybe($result);
  664. }
  665. return new Maybe();
  666. }
  667. /**
  668. * This method is generated.
  669. * Documentation taken from corresponding module.
  670. * ----------------------------------------------
  671. *
  672. * Perform a click on link or button.
  673. * Link or button are found by their names or CSS selector.
  674. * Submits a form if button is a submit type.
  675. *
  676. * If link is an image it's found by alt attribute value of image.
  677. * If button is image button is found by it's value
  678. * If link or button can't be found by name they are searched by CSS selector.
  679. *
  680. * The second parameter is a context: CSS or XPath locator to narrow the search.
  681. *
  682. * Examples:
  683. *
  684. * ``` php
  685. * <?php
  686. * // simple link
  687. * $I->click('Logout');
  688. * // button of form
  689. * $I->click('Submit');
  690. * // CSS button
  691. * $I->click('#form input[type=submit]');
  692. * // XPath
  693. * $I->click('//form/*[@type=submit]')
  694. * // link in context
  695. * $I->click('Logout', '#nav');
  696. * ?>
  697. * ```
  698. * @param $link
  699. * @param $context
  700. * @see Codeception\Util\Mink::click()
  701. * @return \Codeception\Maybe
  702. */
  703. public function click($link, $context = null) {
  704. $this->scenario->addStep(new \Codeception\Step\Action('click', func_get_args()));
  705. if ($this->scenario->running()) {
  706. $result = $this->scenario->runStep();
  707. return new Maybe($result);
  708. }
  709. return new Maybe();
  710. }
  711. /**
  712. * This method is generated.
  713. * Documentation taken from corresponding module.
  714. * ----------------------------------------------
  715. *
  716. * Checks if element exists on a page, matching it by CSS or XPath
  717. *
  718. * ``` php
  719. * <?php
  720. * $I->seeElement('.error');
  721. * $I->seeElement('//form/input[1]');
  722. * ?>
  723. * ```
  724. * @param $selector
  725. * Conditional Assertion: Test won't be stopped on fail
  726. * @see Codeception\Util\Mink::seeElement()
  727. * @return \Codeception\Maybe
  728. */
  729. public function canSeeElement($selector) {
  730. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args()));
  731. if ($this->scenario->running()) {
  732. $result = $this->scenario->runStep();
  733. return new Maybe($result);
  734. }
  735. return new Maybe();
  736. }
  737. /**
  738. * This method is generated.
  739. * Documentation taken from corresponding module.
  740. * ----------------------------------------------
  741. *
  742. * Checks if element exists on a page, matching it by CSS or XPath
  743. *
  744. * ``` php
  745. * <?php
  746. * $I->seeElement('.error');
  747. * $I->seeElement('//form/input[1]');
  748. * ?>
  749. * ```
  750. * @param $selector
  751. * @see Codeception\Util\Mink::seeElement()
  752. * @return \Codeception\Maybe
  753. */
  754. public function seeElement($selector) {
  755. $this->scenario->addStep(new \Codeception\Step\Assertion('seeElement', func_get_args()));
  756. if ($this->scenario->running()) {
  757. $result = $this->scenario->runStep();
  758. return new Maybe($result);
  759. }
  760. return new Maybe();
  761. }
  762. /**
  763. * This method is generated.
  764. * Documentation taken from corresponding module.
  765. * ----------------------------------------------
  766. *
  767. * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
  768. *
  769. * Example:
  770. *
  771. * ``` php
  772. * <?php
  773. * $I->dontSeeElement('.error');
  774. * $I->dontSeeElement('//form/input[1]');
  775. * ?>
  776. * ```
  777. * @param $selector
  778. * Conditional Assertion: Test won't be stopped on fail
  779. * @see Codeception\Util\Mink::dontSeeElement()
  780. * @return \Codeception\Maybe
  781. */
  782. public function cantSeeElement($selector) {
  783. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args()));
  784. if ($this->scenario->running()) {
  785. $result = $this->scenario->runStep();
  786. return new Maybe($result);
  787. }
  788. return new Maybe();
  789. }
  790. /**
  791. * This method is generated.
  792. * Documentation taken from corresponding module.
  793. * ----------------------------------------------
  794. *
  795. * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath
  796. *
  797. * Example:
  798. *
  799. * ``` php
  800. * <?php
  801. * $I->dontSeeElement('.error');
  802. * $I->dontSeeElement('//form/input[1]');
  803. * ?>
  804. * ```
  805. * @param $selector
  806. * @see Codeception\Util\Mink::dontSeeElement()
  807. * @return \Codeception\Maybe
  808. */
  809. public function dontSeeElement($selector) {
  810. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args()));
  811. if ($this->scenario->running()) {
  812. $result = $this->scenario->runStep();
  813. return new Maybe($result);
  814. }
  815. return new Maybe();
  816. }
  817. /**
  818. * This method is generated.
  819. * Documentation taken from corresponding module.
  820. * ----------------------------------------------
  821. *
  822. * Reloads current page
  823. * @see Codeception\Util\Mink::reloadPage()
  824. * @return \Codeception\Maybe
  825. */
  826. public function reloadPage() {
  827. $this->scenario->addStep(new \Codeception\Step\Action('reloadPage', func_get_args()));
  828. if ($this->scenario->running()) {
  829. $result = $this->scenario->runStep();
  830. return new Maybe($result);
  831. }
  832. return new Maybe();
  833. }
  834. /**
  835. * This method is generated.
  836. * Documentation taken from corresponding module.
  837. * ----------------------------------------------
  838. *
  839. * Moves back in history
  840. * @see Codeception\Util\Mink::moveBack()
  841. * @return \Codeception\Maybe
  842. */
  843. public function moveBack() {
  844. $this->scenario->addStep(new \Codeception\Step\Action('moveBack', func_get_args()));
  845. if ($this->scenario->running()) {
  846. $result = $this->scenario->runStep();
  847. return new Maybe($result);
  848. }
  849. return new Maybe();
  850. }
  851. /**
  852. * This method is generated.
  853. * Documentation taken from corresponding module.
  854. * ----------------------------------------------
  855. *
  856. * Moves forward in history
  857. * @see Codeception\Util\Mink::moveForward()
  858. * @return \Codeception\Maybe
  859. */
  860. public function moveForward() {
  861. $this->scenario->addStep(new \Codeception\Step\Action('moveForward', func_get_args()));
  862. if ($this->scenario->running()) {
  863. $result = $this->scenario->runStep();
  864. return new Maybe($result);
  865. }
  866. return new Maybe();
  867. }
  868. /**
  869. * This method is generated.
  870. * Documentation taken from corresponding module.
  871. * ----------------------------------------------
  872. *
  873. * Fills a text field or textarea with value.
  874. *
  875. * Example:
  876. *
  877. * ``` php
  878. * <?php
  879. * $I->fillField("//input[@type='text']", "Hello World!");
  880. * ?>
  881. * ```
  882. *
  883. * @param $field
  884. * @param $value
  885. * @see Codeception\Util\Mink::fillField()
  886. * @return \Codeception\Maybe
  887. */
  888. public function fillField($field, $value) {
  889. $this->scenario->addStep(new \Codeception\Step\Action('fillField', func_get_args()));
  890. if ($this->scenario->running()) {
  891. $result = $this->scenario->runStep();
  892. return new Maybe($result);
  893. }
  894. return new Maybe();
  895. }
  896. /**
  897. * This method is generated.
  898. * Documentation taken from corresponding module.
  899. * ----------------------------------------------
  900. *
  901. * Selects an option in select tag or in radio button group.
  902. *
  903. * Example:
  904. *
  905. * ``` php
  906. * <?php
  907. * $I->selectOption('form select[name=account]', 'Premium');
  908. * $I->selectOption('form input[name=payment]', 'Monthly');
  909. * $I->selectOption('//form/select[@name=account]', 'Monthly');
  910. * ?>
  911. * ```
  912. *
  913. * Can select multiple options if second argument is array:
  914. *
  915. * ``` php
  916. * <?php
  917. * $I->selectOption('Which OS do you use?', array('Windows','Linux'));
  918. * ?>
  919. * ```
  920. *
  921. * @param $select
  922. * @param $option
  923. * @see Codeception\Util\Mink::selectOption()
  924. * @return \Codeception\Maybe
  925. */
  926. public function selectOption($select, $option) {
  927. $this->scenario->addStep(new \Codeception\Step\Action('selectOption', func_get_args()));
  928. if ($this->scenario->running()) {
  929. $result = $this->scenario->runStep();
  930. return new Maybe($result);
  931. }
  932. return new Maybe();
  933. }
  934. /**
  935. * This method is generated.
  936. * Documentation taken from corresponding module.
  937. * ----------------------------------------------
  938. *
  939. * Ticks a checkbox.
  940. * For radio buttons use `selectOption` method.
  941. *
  942. * Example:
  943. *
  944. * ``` php
  945. * <?php
  946. * $I->checkOption('#agree');
  947. * ?>
  948. * ```
  949. *
  950. * @param $option
  951. * @see Codeception\Util\Mink::checkOption()
  952. * @return \Codeception\Maybe
  953. */
  954. public function checkOption($option) {
  955. $this->scenario->addStep(new \Codeception\Step\Action('checkOption', func_get_args()));
  956. if ($this->scenario->running()) {
  957. $result = $this->scenario->runStep();
  958. return new Maybe($result);
  959. }
  960. return new Maybe();
  961. }
  962. /**
  963. * This method is generated.
  964. * Documentation taken from corresponding module.
  965. * ----------------------------------------------
  966. *
  967. * Unticks a checkbox.
  968. *
  969. * Example:
  970. *
  971. * ``` php
  972. * <?php
  973. * $I->uncheckOption('#notify');
  974. * ?>
  975. * ```
  976. *
  977. * @param $option
  978. * @see Codeception\Util\Mink::uncheckOption()
  979. * @return \Codeception\Maybe
  980. */
  981. public function uncheckOption($option) {
  982. $this->scenario->addStep(new \Codeception\Step\Action('uncheckOption', func_get_args()));
  983. if ($this->scenario->running()) {
  984. $result = $this->scenario->runStep();
  985. return new Maybe($result);
  986. }
  987. return new Maybe();
  988. }
  989. /**
  990. * This method is generated.
  991. * Documentation taken from corresponding module.
  992. * ----------------------------------------------
  993. *
  994. * Checks that current uri contains a value
  995. *
  996. * ``` php
  997. * <?php
  998. * // to match: /home/dashboard
  999. * $I->seeInCurrentUrl('home');
  1000. * // to match: /users/1
  1001. * $I->seeInCurrentUrl('/users/');
  1002. * ?>
  1003. * ```
  1004. *
  1005. * @param $uri
  1006. * Conditional Assertion: Test won't be stopped on fail
  1007. * @see Codeception\Util\Mink::seeInCurrentUrl()
  1008. * @return \Codeception\Maybe
  1009. */
  1010. public function canSeeInCurrentUrl($uri) {
  1011. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
  1012. if ($this->scenario->running()) {
  1013. $result = $this->scenario->runStep();
  1014. return new Maybe($result);
  1015. }
  1016. return new Maybe();
  1017. }
  1018. /**
  1019. * This method is generated.
  1020. * Documentation taken from corresponding module.
  1021. * ----------------------------------------------
  1022. *
  1023. * Checks that current uri contains a value
  1024. *
  1025. * ``` php
  1026. * <?php
  1027. * // to match: /home/dashboard
  1028. * $I->seeInCurrentUrl('home');
  1029. * // to match: /users/1
  1030. * $I->seeInCurrentUrl('/users/');
  1031. * ?>
  1032. * ```
  1033. *
  1034. * @param $uri
  1035. * @see Codeception\Util\Mink::seeInCurrentUrl()
  1036. * @return \Codeception\Maybe
  1037. */
  1038. public function seeInCurrentUrl($uri) {
  1039. $this->scenario->addStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
  1040. if ($this->scenario->running()) {
  1041. $result = $this->scenario->runStep();
  1042. return new Maybe($result);
  1043. }
  1044. return new Maybe();
  1045. }
  1046. /**
  1047. * This method is generated.
  1048. * Documentation taken from corresponding module.
  1049. * ----------------------------------------------
  1050. *
  1051. * Checks that current uri does not contain a value
  1052. *
  1053. * ``` php
  1054. * <?php
  1055. * $I->dontSeeInCurrentUrl('/users/');
  1056. * ?>
  1057. * ```
  1058. *
  1059. * @param $uri
  1060. * Conditional Assertion: Test won't be stopped on fail
  1061. * @see Codeception\Util\Mink::dontSeeInCurrentUrl()
  1062. * @return \Codeception\Maybe
  1063. */
  1064. public function cantSeeInCurrentUrl($uri) {
  1065. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
  1066. if ($this->scenario->running()) {
  1067. $result = $this->scenario->runStep();
  1068. return new Maybe($result);
  1069. }
  1070. return new Maybe();
  1071. }
  1072. /**
  1073. * This method is generated.
  1074. * Documentation taken from corresponding module.
  1075. * ----------------------------------------------
  1076. *
  1077. * Checks that current uri does not contain a value
  1078. *
  1079. * ``` php
  1080. * <?php
  1081. * $I->dontSeeInCurrentUrl('/users/');
  1082. * ?>
  1083. * ```
  1084. *
  1085. * @param $uri
  1086. * @see Codeception\Util\Mink::dontSeeInCurrentUrl()
  1087. * @return \Codeception\Maybe
  1088. */
  1089. public function dontSeeInCurrentUrl($uri) {
  1090. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args()));
  1091. if ($this->scenario->running()) {
  1092. $result = $this->scenario->runStep();
  1093. return new Maybe($result);
  1094. }
  1095. return new Maybe();
  1096. }
  1097. /**
  1098. * This method is generated.
  1099. * Documentation taken from corresponding module.
  1100. * ----------------------------------------------
  1101. *
  1102. * Checks that current url is equal to value.
  1103. * Unlike `seeInCurrentUrl` performs a strict check.
  1104. *
  1105. * ``` php
  1106. * <?php
  1107. * // to match root url
  1108. * $I->seeCurrentUrlEquals('/');
  1109. * ?>
  1110. * ```
  1111. *
  1112. * @param $uri
  1113. * Conditional Assertion: Test won't be stopped on fail
  1114. * @see Codeception\Util\Mink::seeCurrentUrlEquals()
  1115. * @return \Codeception\Maybe
  1116. */
  1117. public function canSeeCurrentUrlEquals($uri) {
  1118. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
  1119. if ($this->scenario->running()) {
  1120. $result = $this->scenario->runStep();
  1121. return new Maybe($result);
  1122. }
  1123. return new Maybe();
  1124. }
  1125. /**
  1126. * This method is generated.
  1127. * Documentation taken from corresponding module.
  1128. * ----------------------------------------------
  1129. *
  1130. * Checks that current url is equal to value.
  1131. * Unlike `seeInCurrentUrl` performs a strict check.
  1132. *
  1133. * ``` php
  1134. * <?php
  1135. * // to match root url
  1136. * $I->seeCurrentUrlEquals('/');
  1137. * ?>
  1138. * ```
  1139. *
  1140. * @param $uri
  1141. * @see Codeception\Util\Mink::seeCurrentUrlEquals()
  1142. * @return \Codeception\Maybe
  1143. */
  1144. public function seeCurrentUrlEquals($uri) {
  1145. $this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
  1146. if ($this->scenario->running()) {
  1147. $result = $this->scenario->runStep();
  1148. return new Maybe($result);
  1149. }
  1150. return new Maybe();
  1151. }
  1152. /**
  1153. * This method is generated.
  1154. * Documentation taken from corresponding module.
  1155. * ----------------------------------------------
  1156. *
  1157. * Checks that current url is not equal to value.
  1158. * Unlike `dontSeeInCurrentUrl` performs a strict check.
  1159. *
  1160. * ``` php
  1161. * <?php
  1162. * // current url is not root
  1163. * $I->dontSeeCurrentUrlEquals('/');
  1164. * ?>
  1165. * ```
  1166. *
  1167. * @param $uri
  1168. * Conditional Assertion: Test won't be stopped on fail
  1169. * @see Codeception\Util\Mink::dontSeeCurrentUrlEquals()
  1170. * @return \Codeception\Maybe
  1171. */
  1172. public function cantSeeCurrentUrlEquals($uri) {
  1173. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
  1174. if ($this->scenario->running()) {
  1175. $result = $this->scenario->runStep();
  1176. return new Maybe($result);
  1177. }
  1178. return new Maybe();
  1179. }
  1180. /**
  1181. * This method is generated.
  1182. * Documentation taken from corresponding module.
  1183. * ----------------------------------------------
  1184. *
  1185. * Checks that current url is not equal to value.
  1186. * Unlike `dontSeeInCurrentUrl` performs a strict check.
  1187. *
  1188. * ``` php
  1189. * <?php
  1190. * // current url is not root
  1191. * $I->dontSeeCurrentUrlEquals('/');
  1192. * ?>
  1193. * ```
  1194. *
  1195. * @param $uri
  1196. * @see Codeception\Util\Mink::dontSeeCurrentUrlEquals()
  1197. * @return \Codeception\Maybe
  1198. */
  1199. public function dontSeeCurrentUrlEquals($uri) {
  1200. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args()));
  1201. if ($this->scenario->running()) {
  1202. $result = $this->scenario->runStep();
  1203. return new Maybe($result);
  1204. }
  1205. return new Maybe();
  1206. }
  1207. /**
  1208. * This method is generated.
  1209. * Documentation taken from corresponding module.
  1210. * ----------------------------------------------
  1211. *
  1212. * Checks that current url is matches a RegEx value
  1213. *
  1214. * ``` php
  1215. * <?php
  1216. * // to match root url
  1217. * $I->seeCurrentUrlMatches('~$/users/(\d+)~');
  1218. * ?>
  1219. * ```
  1220. *
  1221. * @param $uri
  1222. * Conditional Assertion: Test won't be stopped on fail
  1223. * @see Codeception\Util\Mink::seeCurrentUrlMatches()
  1224. * @return \Codeception\Maybe
  1225. */
  1226. public function canSeeCurrentUrlMatches($uri) {
  1227. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
  1228. if ($this->scenario->running()) {
  1229. $result = $this->scenario->runStep();
  1230. return new Maybe($result);
  1231. }
  1232. return new Maybe();
  1233. }
  1234. /**
  1235. * This method is generated.
  1236. * Documentation taken from corresponding module.
  1237. * ----------------------------------------------
  1238. *
  1239. * Checks that current url is matches a RegEx value
  1240. *
  1241. * ``` php
  1242. * <?php
  1243. * // to match root url
  1244. * $I->seeCurrentUrlMatches('~$/users/(\d+)~');
  1245. * ?>
  1246. * ```
  1247. *
  1248. * @param $uri
  1249. * @see Codeception\Util\Mink::seeCurrentUrlMatches()
  1250. * @return \Codeception\Maybe
  1251. */
  1252. public function seeCurrentUrlMatches($uri) {
  1253. $this->scenario->addStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
  1254. if ($this->scenario->running()) {
  1255. $result = $this->scenario->runStep();
  1256. return new Maybe($result);
  1257. }
  1258. return new Maybe();
  1259. }
  1260. /**
  1261. * This method is generated.
  1262. * Documentation taken from corresponding module.
  1263. * ----------------------------------------------
  1264. *
  1265. * Checks that current url does not match a RegEx value
  1266. *
  1267. * ``` php
  1268. * <?php
  1269. * // to match root url
  1270. * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
  1271. * ?>
  1272. * ```
  1273. *
  1274. * @param $uri
  1275. * Conditional Assertion: Test won't be stopped on fail
  1276. * @see Codeception\Util\Mink::dontSeeCurrentUrlMatches()
  1277. * @return \Codeception\Maybe
  1278. */
  1279. public function cantSeeCurrentUrlMatches($uri) {
  1280. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
  1281. if ($this->scenario->running()) {
  1282. $result = $this->scenario->runStep();
  1283. return new Maybe($result);
  1284. }
  1285. return new Maybe();
  1286. }
  1287. /**
  1288. * This method is generated.
  1289. * Documentation taken from corresponding module.
  1290. * ----------------------------------------------
  1291. *
  1292. * Checks that current url does not match a RegEx value
  1293. *
  1294. * ``` php
  1295. * <?php
  1296. * // to match root url
  1297. * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
  1298. * ?>
  1299. * ```
  1300. *
  1301. * @param $uri
  1302. * @see Codeception\Util\Mink::dontSeeCurrentUrlMatches()
  1303. * @return \Codeception\Maybe
  1304. */
  1305. public function dontSeeCurrentUrlMatches($uri) {
  1306. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args()));
  1307. if ($this->scenario->running()) {
  1308. $result = $this->scenario->runStep();
  1309. return new Maybe($result);
  1310. }
  1311. return new Maybe();
  1312. }
  1313. /**
  1314. * This method is generated.
  1315. * Documentation taken from corresponding module.
  1316. * ----------------------------------------------
  1317. *
  1318. * Checks that cookie is set.
  1319. *
  1320. * @param $cookie
  1321. * @return mixed
  1322. * Conditional Assertion: Test won't be stopped on fail
  1323. * @see Codeception\Util\Mink::seeCookie()
  1324. * @return \Codeception\Maybe
  1325. */
  1326. public function canSeeCookie($cookie) {
  1327. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args()));
  1328. if ($this->scenario->running()) {
  1329. $result = $this->scenario->runStep();
  1330. return new Maybe($result);
  1331. }
  1332. return new Maybe();
  1333. }
  1334. /**
  1335. * This method is generated.
  1336. * Documentation taken from corresponding module.
  1337. * ----------------------------------------------
  1338. *
  1339. * Checks that cookie is set.
  1340. *
  1341. * @param $cookie
  1342. * @return mixed
  1343. * @see Codeception\Util\Mink::seeCookie()
  1344. * @return \Codeception\Maybe
  1345. */
  1346. public function seeCookie($cookie) {
  1347. $this->scenario->addStep(new \Codeception\Step\Assertion('seeCookie', func_get_args()));
  1348. if ($this->scenario->running()) {
  1349. $result = $this->scenario->runStep();
  1350. return new Maybe($result);
  1351. }
  1352. return new Maybe();
  1353. }
  1354. /**
  1355. * This method is generated.
  1356. * Documentation taken from corresponding module.
  1357. * ----------------------------------------------
  1358. *
  1359. * Checks that cookie doesn't exist
  1360. *
  1361. * @param $cookie
  1362. * @return mixed
  1363. * Conditional Assertion: Test won't be stopped on fail
  1364. * @see Codeception\Util\Mink::dontSeeCookie()
  1365. * @return \Codeception\Maybe
  1366. */
  1367. public function cantSeeCookie($cookie) {
  1368. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args()));
  1369. if ($this->scenario->running()) {
  1370. $result = $this->scenario->runStep();
  1371. return new Maybe($result);
  1372. }
  1373. return new Maybe();
  1374. }
  1375. /**
  1376. * This method is generated.
  1377. * Documentation taken from corresponding module.
  1378. * ----------------------------------------------
  1379. *
  1380. * Checks that cookie doesn't exist
  1381. *
  1382. * @param $cookie
  1383. * @return mixed
  1384. * @see Codeception\Util\Mink::dontSeeCookie()
  1385. * @return \Codeception\Maybe
  1386. */
  1387. public function dontSeeCookie($cookie) {
  1388. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args()));
  1389. if ($this->scenario->running()) {
  1390. $result = $this->scenario->runStep();
  1391. return new Maybe($result);
  1392. }
  1393. return new Maybe();
  1394. }
  1395. /**
  1396. * This method is generated.
  1397. * Documentation taken from corresponding module.
  1398. * ----------------------------------------------
  1399. *
  1400. * Sets a cookie.
  1401. *
  1402. * @param $cookie
  1403. * @param $value
  1404. * @return mixed
  1405. * @see Codeception\Util\Mink::setCookie()
  1406. * @return \Codeception\Maybe
  1407. */
  1408. public function setCookie($cookie, $value) {
  1409. $this->scenario->addStep(new \Codeception\Step\Action('setCookie', func_get_args()));
  1410. if ($this->scenario->running()) {
  1411. $result = $this->scenario->runStep();
  1412. return new Maybe($result);
  1413. }
  1414. return new Maybe();
  1415. }
  1416. /**
  1417. * This method is generated.
  1418. * Documentation taken from corresponding module.
  1419. * ----------------------------------------------
  1420. *
  1421. * Unsets cookie
  1422. *
  1423. * @param $cookie
  1424. * @return mixed
  1425. * @see Codeception\Util\Mink::resetCookie()
  1426. * @return \Codeception\Maybe
  1427. */
  1428. public function resetCookie($cookie) {
  1429. $this->scenario->addStep(new \Codeception\Step\Action('resetCookie', func_get_args()));
  1430. if ($this->scenario->running()) {
  1431. $result = $this->scenario->runStep();
  1432. return new Maybe($result);
  1433. }
  1434. return new Maybe();
  1435. }
  1436. /**
  1437. * This method is generated.
  1438. * Documentation taken from corresponding module.
  1439. * ----------------------------------------------
  1440. *
  1441. * Grabs a cookie value.
  1442. *
  1443. * @param $cookie
  1444. * @return mixed
  1445. * @see Codeception\Util\Mink::grabCookie()
  1446. * @return \Codeception\Maybe
  1447. */
  1448. public function grabCookie($cookie) {
  1449. $this->scenario->addStep(new \Codeception\Step\Action('grabCookie', func_get_args()));
  1450. if ($this->scenario->running()) {
  1451. $result = $this->scenario->runStep();
  1452. return new Maybe($result);
  1453. }
  1454. return new Maybe();
  1455. }
  1456. /**
  1457. * This method is generated.
  1458. * Documentation taken from corresponding module.
  1459. * ----------------------------------------------
  1460. *
  1461. * Takes a parameters from current URI by RegEx.
  1462. * If no url provided returns full URI.
  1463. *
  1464. * ``` php
  1465. * <?php
  1466. * $user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~');
  1467. * $uri = $I->grabFromCurrentUrl();
  1468. * ?>
  1469. * ```
  1470. *
  1471. * @param null $uri
  1472. * @internal param $url
  1473. * @return mixed
  1474. * @see Codeception\Util\Mink::grabFromCurrentUrl()
  1475. * @return \Codeception\Maybe
  1476. */
  1477. public function grabFromCurrentUrl($uri = null) {
  1478. $this->scenario->addStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
  1479. if ($this->scenario->running()) {
  1480. $result = $this->scenario->runStep();
  1481. return new Maybe($result);
  1482. }
  1483. return new Maybe();
  1484. }
  1485. /**
  1486. * This method is generated.
  1487. * Documentation taken from corresponding module.
  1488. * ----------------------------------------------
  1489. *
  1490. * Attaches file from Codeception data directory to upload field.
  1491. *
  1492. * Example:
  1493. *
  1494. * ``` php
  1495. * <?php
  1496. * // file is stored in 'tests/_data/prices.xls'
  1497. * $I->attachFile('input[@type="file"]', 'prices.xls');
  1498. * ?>
  1499. * ```
  1500. *
  1501. * @param $field
  1502. * @param $filename
  1503. * @see Codeception\Util\Mink::attachFile()
  1504. * @return \Codeception\Maybe
  1505. */
  1506. public function attachFile($field, $filename) {
  1507. $this->scenario->addStep(new \Codeception\Step\Action('attachFile', func_get_args()));
  1508. if ($this->scenario->running()) {
  1509. $result = $this->scenario->runStep();
  1510. return new Maybe($result);
  1511. }
  1512. return new Maybe();
  1513. }
  1514. /**
  1515. * This method is generated.
  1516. * Documentation taken from corresponding module.
  1517. * ----------------------------------------------
  1518. *
  1519. * Checks if option is selected in select field.
  1520. *
  1521. * ``` php
  1522. * <?php
  1523. * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
  1524. * ?>
  1525. * ```
  1526. *
  1527. * @param $selector
  1528. * @param $optionText
  1529. * @return mixed
  1530. * Conditional Assertion: Test won't be stopped on fail
  1531. * @see Codeception\Util\Mink::seeOptionIsSelected()
  1532. * @return \Codeception\Maybe
  1533. */
  1534. public function canSeeOptionIsSelected($select, $text) {
  1535. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args()));
  1536. if ($this->scenario->running()) {
  1537. $result = $this->scenario->runStep();
  1538. return new Maybe($result);
  1539. }
  1540. return new Maybe();
  1541. }
  1542. /**
  1543. * This method is generated.
  1544. * Documentation taken from corresponding module.
  1545. * ----------------------------------------------
  1546. *
  1547. * Checks if option is selected in select field.
  1548. *
  1549. * ``` php
  1550. * <?php
  1551. * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
  1552. * ?>
  1553. * ```
  1554. *
  1555. * @param $selector
  1556. * @param $optionText
  1557. * @return mixed
  1558. * @see Codeception\Util\Mink::seeOptionIsSelected()
  1559. * @return \Codeception\Maybe
  1560. */
  1561. public function seeOptionIsSelected($select, $text) {
  1562. $this->scenario->addStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args()));
  1563. if ($this->scenario->running()) {
  1564. $result = $this->scenario->runStep();
  1565. return new Maybe($result);
  1566. }
  1567. return new Maybe();
  1568. }
  1569. /**
  1570. * This method is generated.
  1571. * Documentation taken from corresponding module.
  1572. * ----------------------------------------------
  1573. *
  1574. * Checks if option is not selected in select field.
  1575. *
  1576. * ``` php
  1577. * <?php
  1578. * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
  1579. * ?>
  1580. * ```
  1581. *
  1582. * @param $selector
  1583. * @param $optionText
  1584. * @return mixed
  1585. * Conditional Assertion: Test won't be stopped on fail
  1586. * @see Codeception\Util\Mink::dontSeeOptionIsSelected()
  1587. * @return \Codeception\Maybe
  1588. */
  1589. public function cantSeeOptionIsSelected($select, $text) {
  1590. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args()));
  1591. if ($this->scenario->running()) {
  1592. $result = $this->scenario->runStep();
  1593. return new Maybe($result);
  1594. }
  1595. return new Maybe();
  1596. }
  1597. /**
  1598. * This method is generated.
  1599. * Documentation taken from corresponding module.
  1600. * ----------------------------------------------
  1601. *
  1602. * Checks if option is not selected in select field.
  1603. *
  1604. * ``` php
  1605. * <?php
  1606. * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
  1607. * ?>
  1608. * ```
  1609. *
  1610. * @param $selector
  1611. * @param $optionText
  1612. * @return mixed
  1613. * @see Codeception\Util\Mink::dontSeeOptionIsSelected()
  1614. * @return \Codeception\Maybe
  1615. */
  1616. public function dontSeeOptionIsSelected($select, $text) {
  1617. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args()));
  1618. if ($this->scenario->running()) {
  1619. $result = $this->scenario->runStep();
  1620. return new Maybe($result);
  1621. }
  1622. return new Maybe();
  1623. }
  1624. /**
  1625. * This method is generated.
  1626. * Documentation taken from corresponding module.
  1627. * ----------------------------------------------
  1628. *
  1629. * Checks that an input field or textarea contains value.
  1630. * Field is matched either by label or CSS or Xpath
  1631. *
  1632. * Example:
  1633. *
  1634. * ``` php
  1635. * <?php
  1636. * $I->seeInField('Body','Type your comment here');
  1637. * $I->seeInField('form textarea[name=body]','Type your comment here');
  1638. * $I->seeInField('form input[type=hidden]','hidden_value');
  1639. * $I->seeInField('#searchform input','Search');
  1640. * $I->seeInField('//form/*[@name=search]','Search');
  1641. * ?>
  1642. * ```
  1643. *
  1644. * @param $field
  1645. * @param $value
  1646. * Conditional Assertion: Test won't be stopped on fail
  1647. * @see Codeception\Util\Mink::seeInField()
  1648. * @return \Codeception\Maybe
  1649. */
  1650. public function canSeeInField($field, $value) {
  1651. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
  1652. if ($this->scenario->running()) {
  1653. $result = $this->scenario->runStep();
  1654. return new Maybe($result);
  1655. }
  1656. return new Maybe();
  1657. }
  1658. /**
  1659. * This method is generated.
  1660. * Documentation taken from corresponding module.
  1661. * ----------------------------------------------
  1662. *
  1663. * Checks that an input field or textarea contains value.
  1664. * Field is matched either by label or CSS or Xpath
  1665. *
  1666. * Example:
  1667. *
  1668. * ``` php
  1669. * <?php
  1670. * $I->seeInField('Body','Type your comment here');
  1671. * $I->seeInField('form textarea[name=body]','Type your comment here');
  1672. * $I->seeInField('form input[type=hidden]','hidden_value');
  1673. * $I->seeInField('#searchform input','Search');
  1674. * $I->seeInField('//form/*[@name=search]','Search');
  1675. * ?>
  1676. * ```
  1677. *
  1678. * @param $field
  1679. * @param $value
  1680. * @see Codeception\Util\Mink::seeInField()
  1681. * @return \Codeception\Maybe
  1682. */
  1683. public function seeInField($field, $value) {
  1684. $this->scenario->addStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
  1685. if ($this->scenario->running()) {
  1686. $result = $this->scenario->runStep();
  1687. return new Maybe($result);
  1688. }
  1689. return new Maybe();
  1690. }
  1691. /**
  1692. * This method is generated.
  1693. * Documentation taken from corresponding module.
  1694. * ----------------------------------------------
  1695. *
  1696. * Checks that an input field or textarea doesn't contain value.
  1697. * Field is matched either by label or CSS or Xpath
  1698. * Example:
  1699. *
  1700. * ``` php
  1701. * <?php
  1702. * $I->dontSeeInField('Body','Type your comment here');
  1703. * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
  1704. * $I->dontSeeInField('form input[type=hidden]','hidden_value');
  1705. * $I->dontSeeInField('#searchform input','Search');
  1706. * $I->dontSeeInField('//form/*[@name=search]','Search');
  1707. * ?>
  1708. * ```
  1709. *
  1710. * @param $field
  1711. * @param $value
  1712. * Conditional Assertion: Test won't be stopped on fail
  1713. * @see Codeception\Util\Mink::dontSeeInField()
  1714. * @return \Codeception\Maybe
  1715. */
  1716. public function cantSeeInField($field, $value) {
  1717. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args()));
  1718. if ($this->scenario->running()) {
  1719. $result = $this->scenario->runStep();
  1720. return new Maybe($result);
  1721. }
  1722. return new Maybe();
  1723. }
  1724. /**
  1725. * This method is generated.
  1726. * Documentation taken from corresponding module.
  1727. * ----------------------------------------------
  1728. *
  1729. * Checks that an input field or textarea doesn't contain value.
  1730. * Field is matched either by label or CSS or Xpath
  1731. * Example:
  1732. *
  1733. * ``` php
  1734. * <?php
  1735. * $I->dontSeeInField('Body','Type your comment here');
  1736. * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
  1737. * $I->dontSeeInField('form input[type=hidden]','hidden_value');
  1738. * $I->dontSeeInField('#searchform input','Search');
  1739. * $I->dontSeeInField('//form/*[@name=search]','Search');
  1740. * ?>
  1741. * ```
  1742. *
  1743. * @param $field
  1744. * @param $value
  1745. * @see Codeception\Util\Mink::dontSeeInField()
  1746. * @return \Codeception\Maybe
  1747. */
  1748. public function dontSeeInField($field, $value) {
  1749. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args()));
  1750. if ($this->scenario->running()) {
  1751. $result = $this->scenario->runStep();
  1752. return new Maybe($result);
  1753. }
  1754. return new Maybe();
  1755. }
  1756. /**
  1757. * This method is generated.
  1758. * Documentation taken from corresponding module.
  1759. * ----------------------------------------------
  1760. *
  1761. * Finds and returns text contents of element.
  1762. * Element is searched by CSS selector, XPath or matcher by regex.
  1763. *
  1764. * Example:
  1765. *
  1766. * ``` php
  1767. * <?php
  1768. * $heading = $I->grabTextFrom('h1');
  1769. * $heading = $I->grabTextFrom('descendant-or-self::h1');
  1770. * $value = $I->grabTextFrom('~<input value=(.*?)]~sgi');
  1771. * ?>
  1772. * ```
  1773. *
  1774. * @param $cssOrXPathOrRegex
  1775. * @return mixed
  1776. * @see Codeception\Util\Mink::grabTextFrom()
  1777. * @return \Codeception\Maybe
  1778. */
  1779. public function grabTextFrom($cssOrXPathOrRegex) {
  1780. $this->scenario->addStep(new \Codeception\Step\Action('grabTextFrom', func_get_args()));
  1781. if ($this->scenario->running()) {
  1782. $result = $this->scenario->runStep();
  1783. return new Maybe($result);
  1784. }
  1785. return new Maybe();
  1786. }
  1787. /**
  1788. * This method is generated.
  1789. * Documentation taken from corresponding module.
  1790. * ----------------------------------------------
  1791. *
  1792. * Finds and returns field and returns it's value.
  1793. * Searches by field name, then by CSS, then by XPath
  1794. *
  1795. * Example:
  1796. *
  1797. * ``` php
  1798. * <?php
  1799. * $name = $I->grabValueFrom('Name');
  1800. * $name = $I->grabValueFrom('input[name=username]');
  1801. * $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']');
  1802. * ?>
  1803. * ```
  1804. *
  1805. * @param $field
  1806. * @return mixed
  1807. * @see Codeception\Util\Mink::grabValueFrom()
  1808. * @return \Codeception\Maybe
  1809. */
  1810. public function grabValueFrom($field) {
  1811. $this->scenario->addStep(new \Codeception\Step\Action('grabValueFrom', func_get_args()));
  1812. if ($this->scenario->running()) {
  1813. $result = $this->scenario->runStep();
  1814. return new Maybe($result);
  1815. }
  1816. return new Maybe();
  1817. }
  1818. /**
  1819. * This method is generated.
  1820. * Documentation taken from corresponding module.
  1821. * ----------------------------------------------
  1822. *
  1823. * Checks that page title contains text.
  1824. *
  1825. * ``` php
  1826. * <?php
  1827. * $I->seeInTitle('Blog - Post #1');
  1828. * ?>
  1829. * ```
  1830. *
  1831. * @param $title
  1832. * @return mixed
  1833. * Conditional Assertion: Test won't be stopped on fail
  1834. * @see Codeception\Util\Mink::seeInTitle()
  1835. * @return \Codeception\Maybe
  1836. */
  1837. public function canSeeInTitle($title) {
  1838. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args()));
  1839. if ($this->scenario->running()) {
  1840. $result = $this->scenario->runStep();
  1841. return new Maybe($result);
  1842. }
  1843. return new Maybe();
  1844. }
  1845. /**
  1846. * This method is generated.
  1847. * Documentation taken from corresponding module.
  1848. * ----------------------------------------------
  1849. *
  1850. * Checks that page title contains text.
  1851. *
  1852. * ``` php
  1853. * <?php
  1854. * $I->seeInTitle('Blog - Post #1');
  1855. * ?>
  1856. * ```
  1857. *
  1858. * @param $title
  1859. * @return mixed
  1860. * @see Codeception\Util\Mink::seeInTitle()
  1861. * @return \Codeception\Maybe
  1862. */
  1863. public function seeInTitle($title) {
  1864. $this->scenario->addStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args()));
  1865. if ($this->scenario->running()) {
  1866. $result = $this->scenario->runStep();
  1867. return new Maybe($result);
  1868. }
  1869. return new Maybe();
  1870. }
  1871. /**
  1872. * This method is generated.
  1873. * Documentation taken from corresponding module.
  1874. * ----------------------------------------------
  1875. *
  1876. * Checks that page title does not contain text.
  1877. *
  1878. * @param $title
  1879. * @return mixed
  1880. * Conditional Assertion: Test won't be stopped on fail
  1881. * @see Codeception\Util\Mink::dontSeeInTitle()
  1882. * @return \Codeception\Maybe
  1883. */
  1884. public function cantSeeInTitle($title) {
  1885. $this->scenario->addStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args()));
  1886. if ($this->scenario->running()) {
  1887. $result = $this->scenario->runStep();
  1888. return new Maybe($result);
  1889. }
  1890. return new Maybe();
  1891. }
  1892. /**
  1893. * This method is generated.
  1894. * Documentation taken from corresponding module.
  1895. * ----------------------------------------------
  1896. *
  1897. * Checks that page title does not contain text.
  1898. *
  1899. * @param $title
  1900. * @return mixed
  1901. * @see Codeception\Util\Mink::dontSeeInTitle()
  1902. * @return \Codeception\Maybe
  1903. */
  1904. public function dontSeeInTitle($title) {
  1905. $this->scenario->addStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args()));
  1906. if ($this->scenario->running()) {
  1907. $result = $this->scenario->runStep();
  1908. return new Maybe($result);
  1909. }
  1910. return new Maybe();
  1911. }
  1912. }