AcceptanceTesterActions.php 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012
  1. <?php //[STAMP] 16f6eb4d62a05efc134e9bd420d7b39b
  2. namespace _generated;
  3. // This class was automatically generated by build task
  4. // You should not change it manually as it will be overwritten on next build
  5. // @codingStandardsIgnoreFile
  6. use Helper\Acceptance;
  7. use Codeception\Module\WebDriver;
  8. use Codeception\Module\VisualCeption;
  9. trait AcceptanceTesterActions
  10. {
  11. /**
  12. * @return \Codeception\Scenario
  13. */
  14. abstract protected function getScenario();
  15. /**
  16. * [!] Method is generated. Documentation taken from corresponding module.
  17. *
  18. * Checks that array contains subset.
  19. *
  20. * @param array $subset
  21. * @param array $array
  22. * @param bool $strict
  23. * @param string $message
  24. * @see \Codeception\Module::assertArraySubset()
  25. */
  26. public function assertArraySubset($subset, $array, $strict = null, $message = null) {
  27. return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
  28. }
  29. /**
  30. * [!] Method is generated. Documentation taken from corresponding module.
  31. *
  32. * Print out latest Selenium Logs in debug mode
  33. *
  34. * @param TestInterface $test
  35. * @see \Codeception\Module\WebDriver::debugWebDriverLogs()
  36. */
  37. public function debugWebDriverLogs($test = null) {
  38. return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWebDriverLogs', func_get_args()));
  39. }
  40. /**
  41. * [!] Method is generated. Documentation taken from corresponding module.
  42. *
  43. * Changes the subdomain for the 'url' configuration parameter.
  44. * Does not open a page; use `amOnPage` for that.
  45. *
  46. * ``` php
  47. * <?php
  48. * // If config is: 'http://mysite.com'
  49. * // or config is: 'http://www.mysite.com'
  50. * // or config is: 'http://company.mysite.com'
  51. *
  52. * $I->amOnSubdomain('user');
  53. * $I->amOnPage('/');
  54. * // moves to http://user.mysite.com/
  55. * ?>
  56. * ```
  57. *
  58. * @param $subdomain
  59. *
  60. * @return mixed
  61. * @see \Codeception\Module\WebDriver::amOnSubdomain()
  62. */
  63. public function amOnSubdomain($subdomain) {
  64. return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args()));
  65. }
  66. /**
  67. * [!] Method is generated. Documentation taken from corresponding module.
  68. *
  69. * Takes a screenshot of the current window and saves it to `tests/_output/debug`.
  70. *
  71. * ``` php
  72. * <?php
  73. * $I->amOnPage('/user/edit');
  74. * $I->makeScreenshot('edit_page');
  75. * // saved to: tests/_output/debug/edit_page.png
  76. * $I->makeScreenshot();
  77. * // saved to: tests/_output/debug/2017-05-26_14-24-11_4b3403665fea6.png
  78. * ```
  79. *
  80. * @param $name
  81. * @see \Codeception\Module\WebDriver::makeScreenshot()
  82. */
  83. public function makeScreenshot($name = null) {
  84. return $this->getScenario()->runStep(new \Codeception\Step\Action('makeScreenshot', func_get_args()));
  85. }
  86. /**
  87. * [!] Method is generated. Documentation taken from corresponding module.
  88. *
  89. * Resize the current window.
  90. *
  91. * ``` php
  92. * <?php
  93. * $I->resizeWindow(800, 600);
  94. *
  95. * ```
  96. *
  97. * @param int $width
  98. * @param int $height
  99. * @see \Codeception\Module\WebDriver::resizeWindow()
  100. */
  101. public function resizeWindow($width, $height) {
  102. return $this->getScenario()->runStep(new \Codeception\Step\Action('resizeWindow', func_get_args()));
  103. }
  104. /**
  105. * [!] Method is generated. Documentation taken from corresponding module.
  106. *
  107. * Checks that a cookie with the given name is set.
  108. * You can set additional cookie params like `domain`, `path` as array passed in last argument.
  109. *
  110. * ``` php
  111. * <?php
  112. * $I->seeCookie('PHPSESSID');
  113. * ?>
  114. * ```
  115. *
  116. * @param $cookie
  117. * @param array $params
  118. * @return mixed
  119. * Conditional Assertion: Test won't be stopped on fail
  120. * @see \Codeception\Module\WebDriver::seeCookie()
  121. */
  122. public function canSeeCookie($cookie, $params = null) {
  123. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args()));
  124. }
  125. /**
  126. * [!] Method is generated. Documentation taken from corresponding module.
  127. *
  128. * Checks that a cookie with the given name is set.
  129. * You can set additional cookie params like `domain`, `path` as array passed in last argument.
  130. *
  131. * ``` php
  132. * <?php
  133. * $I->seeCookie('PHPSESSID');
  134. * ?>
  135. * ```
  136. *
  137. * @param $cookie
  138. * @param array $params
  139. * @return mixed
  140. * @see \Codeception\Module\WebDriver::seeCookie()
  141. */
  142. public function seeCookie($cookie, $params = null) {
  143. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args()));
  144. }
  145. /**
  146. * [!] Method is generated. Documentation taken from corresponding module.
  147. *
  148. * Checks that there isn't a cookie with the given name.
  149. * You can set additional cookie params like `domain`, `path` as array passed in last argument.
  150. *
  151. * @param $cookie
  152. *
  153. * @param array $params
  154. * @return mixed
  155. * Conditional Assertion: Test won't be stopped on fail
  156. * @see \Codeception\Module\WebDriver::dontSeeCookie()
  157. */
  158. public function cantSeeCookie($cookie, $params = null) {
  159. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args()));
  160. }
  161. /**
  162. * [!] Method is generated. Documentation taken from corresponding module.
  163. *
  164. * Checks that there isn't a cookie with the given name.
  165. * You can set additional cookie params like `domain`, `path` as array passed in last argument.
  166. *
  167. * @param $cookie
  168. *
  169. * @param array $params
  170. * @return mixed
  171. * @see \Codeception\Module\WebDriver::dontSeeCookie()
  172. */
  173. public function dontSeeCookie($cookie, $params = null) {
  174. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args()));
  175. }
  176. /**
  177. * [!] Method is generated. Documentation taken from corresponding module.
  178. *
  179. * Sets a cookie with the given name and value.
  180. * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument.
  181. *
  182. * ``` php
  183. * <?php
  184. * $I->setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3');
  185. * ?>
  186. * ```
  187. *
  188. * @param $name
  189. * @param $val
  190. * @param array $params
  191. *
  192. * @return mixed
  193. * @see \Codeception\Module\WebDriver::setCookie()
  194. */
  195. public function setCookie($cookie, $value, $params = null) {
  196. return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args()));
  197. }
  198. /**
  199. * [!] Method is generated. Documentation taken from corresponding module.
  200. *
  201. * Unsets cookie with the given name.
  202. * You can set additional cookie params like `domain`, `path` in array passed as last argument.
  203. *
  204. * @param $cookie
  205. *
  206. * @param array $params
  207. * @return mixed
  208. * @see \Codeception\Module\WebDriver::resetCookie()
  209. */
  210. public function resetCookie($cookie, $params = null) {
  211. return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args()));
  212. }
  213. /**
  214. * [!] Method is generated. Documentation taken from corresponding module.
  215. *
  216. * Grabs a cookie value.
  217. * You can set additional cookie params like `domain`, `path` in array passed as last argument.
  218. *
  219. * @param $cookie
  220. *
  221. * @param array $params
  222. * @return mixed
  223. * @see \Codeception\Module\WebDriver::grabCookie()
  224. */
  225. public function grabCookie($cookie, $params = null) {
  226. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args()));
  227. }
  228. /**
  229. * [!] Method is generated. Documentation taken from corresponding module.
  230. *
  231. * Grabs current page source code.
  232. *
  233. * @throws ModuleException if no page was opened.
  234. *
  235. * @return string Current page source code.
  236. * @see \Codeception\Module\WebDriver::grabPageSource()
  237. */
  238. public function grabPageSource() {
  239. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabPageSource', func_get_args()));
  240. }
  241. /**
  242. * [!] Method is generated. Documentation taken from corresponding module.
  243. *
  244. * Open web page at the given absolute URL and sets its hostname as the base host.
  245. *
  246. * ``` php
  247. * <?php
  248. * $I->amOnUrl('http://codeception.com');
  249. * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart
  250. * ?>
  251. * ```
  252. * @see \Codeception\Module\WebDriver::amOnUrl()
  253. */
  254. public function amOnUrl($url) {
  255. return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args()));
  256. }
  257. /**
  258. * [!] Method is generated. Documentation taken from corresponding module.
  259. *
  260. * Opens the page for the given relative URI.
  261. *
  262. * ``` php
  263. * <?php
  264. * // opens front page
  265. * $I->amOnPage('/');
  266. * // opens /register page
  267. * $I->amOnPage('/register');
  268. * ```
  269. *
  270. * @param string $page
  271. * @see \Codeception\Module\WebDriver::amOnPage()
  272. */
  273. public function amOnPage($page) {
  274. return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
  275. }
  276. /**
  277. * [!] Method is generated. Documentation taken from corresponding module.
  278. *
  279. * Checks that the current page contains the given string (case insensitive).
  280. *
  281. * You can specify a specific HTML element (via CSS or XPath) as the second
  282. * parameter to only search within that element.
  283. *
  284. * ``` php
  285. * <?php
  286. * $I->see('Logout'); // I can suppose user is logged in
  287. * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
  288. * $I->see('Sign Up', '//body/h1'); // with XPath
  289. * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
  290. * ```
  291. *
  292. * Note that the search is done after stripping all HTML tags from the body,
  293. * so `$I->see('strong')` will return true for strings like:
  294. *
  295. * - `<p>I am Stronger than thou</p>`
  296. * - `<script>document.createElement('strong');</script>`
  297. *
  298. * But will *not* be true for strings like:
  299. *
  300. * - `<strong>Home</strong>`
  301. * - `<div class="strong">Home</strong>`
  302. * - `<!-- strong -->`
  303. *
  304. * For checking the raw source code, use `seeInSource()`.
  305. *
  306. * @param string $text
  307. * @param string $selector optional
  308. * Conditional Assertion: Test won't be stopped on fail
  309. * @see \Codeception\Module\WebDriver::see()
  310. */
  311. public function canSee($text, $selector = null) {
  312. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
  313. }
  314. /**
  315. * [!] Method is generated. Documentation taken from corresponding module.
  316. *
  317. * Checks that the current page contains the given string (case insensitive).
  318. *
  319. * You can specify a specific HTML element (via CSS or XPath) as the second
  320. * parameter to only search within that element.
  321. *
  322. * ``` php
  323. * <?php
  324. * $I->see('Logout'); // I can suppose user is logged in
  325. * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
  326. * $I->see('Sign Up', '//body/h1'); // with XPath
  327. * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
  328. * ```
  329. *
  330. * Note that the search is done after stripping all HTML tags from the body,
  331. * so `$I->see('strong')` will return true for strings like:
  332. *
  333. * - `<p>I am Stronger than thou</p>`
  334. * - `<script>document.createElement('strong');</script>`
  335. *
  336. * But will *not* be true for strings like:
  337. *
  338. * - `<strong>Home</strong>`
  339. * - `<div class="strong">Home</strong>`
  340. * - `<!-- strong -->`
  341. *
  342. * For checking the raw source code, use `seeInSource()`.
  343. *
  344. * @param string $text
  345. * @param string $selector optional
  346. * @see \Codeception\Module\WebDriver::see()
  347. */
  348. public function see($text, $selector = null) {
  349. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args()));
  350. }
  351. /**
  352. * [!] Method is generated. Documentation taken from corresponding module.
  353. *
  354. * Checks that the current page doesn't contain the text specified (case insensitive).
  355. * Give a locator as the second parameter to match a specific region.
  356. *
  357. * ```php
  358. * <?php
  359. * $I->dontSee('Login'); // I can suppose user is already logged in
  360. * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
  361. * $I->dontSee('Sign Up','//body/h1'); // with XPath
  362. * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
  363. * ```
  364. *
  365. * Note that the search is done after stripping all HTML tags from the body,
  366. * so `$I->dontSee('strong')` will fail on strings like:
  367. *
  368. * - `<p>I am Stronger than thou</p>`
  369. * - `<script>document.createElement('strong');</script>`
  370. *
  371. * But will ignore strings like:
  372. *
  373. * - `<strong>Home</strong>`
  374. * - `<div class="strong">Home</strong>`
  375. * - `<!-- strong -->`
  376. *
  377. * For checking the raw source code, use `seeInSource()`.
  378. *
  379. * @param string $text
  380. * @param string $selector optional
  381. * Conditional Assertion: Test won't be stopped on fail
  382. * @see \Codeception\Module\WebDriver::dontSee()
  383. */
  384. public function cantSee($text, $selector = null) {
  385. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
  386. }
  387. /**
  388. * [!] Method is generated. Documentation taken from corresponding module.
  389. *
  390. * Checks that the current page doesn't contain the text specified (case insensitive).
  391. * Give a locator as the second parameter to match a specific region.
  392. *
  393. * ```php
  394. * <?php
  395. * $I->dontSee('Login'); // I can suppose user is already logged in
  396. * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
  397. * $I->dontSee('Sign Up','//body/h1'); // with XPath
  398. * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
  399. * ```
  400. *
  401. * Note that the search is done after stripping all HTML tags from the body,
  402. * so `$I->dontSee('strong')` will fail on strings like:
  403. *
  404. * - `<p>I am Stronger than thou</p>`
  405. * - `<script>document.createElement('strong');</script>`
  406. *
  407. * But will ignore strings like:
  408. *
  409. * - `<strong>Home</strong>`
  410. * - `<div class="strong">Home</strong>`
  411. * - `<!-- strong -->`
  412. *
  413. * For checking the raw source code, use `seeInSource()`.
  414. *
  415. * @param string $text
  416. * @param string $selector optional
  417. * @see \Codeception\Module\WebDriver::dontSee()
  418. */
  419. public function dontSee($text, $selector = null) {
  420. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args()));
  421. }
  422. /**
  423. * [!] Method is generated. Documentation taken from corresponding module.
  424. *
  425. * Checks that the current page contains the given string in its
  426. * raw source code.
  427. *
  428. * ``` php
  429. * <?php
  430. * $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
  431. * ```
  432. *
  433. * @param $raw
  434. * Conditional Assertion: Test won't be stopped on fail
  435. * @see \Codeception\Module\WebDriver::seeInSource()
  436. */
  437. public function canSeeInSource($raw) {
  438. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args()));
  439. }
  440. /**
  441. * [!] Method is generated. Documentation taken from corresponding module.
  442. *
  443. * Checks that the current page contains the given string in its
  444. * raw source code.
  445. *
  446. * ``` php
  447. * <?php
  448. * $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
  449. * ```
  450. *
  451. * @param $raw
  452. * @see \Codeception\Module\WebDriver::seeInSource()
  453. */
  454. public function seeInSource($raw) {
  455. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args()));
  456. }
  457. /**
  458. * [!] Method is generated. Documentation taken from corresponding module.
  459. *
  460. * Checks that the current page contains the given string in its
  461. * raw source code.
  462. *
  463. * ```php
  464. * <?php
  465. * $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
  466. * ```
  467. *
  468. * @param $raw
  469. * Conditional Assertion: Test won't be stopped on fail
  470. * @see \Codeception\Module\WebDriver::dontSeeInSource()
  471. */
  472. public function cantSeeInSource($raw) {
  473. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args()));
  474. }
  475. /**
  476. * [!] Method is generated. Documentation taken from corresponding module.
  477. *
  478. * Checks that the current page contains the given string in its
  479. * raw source code.
  480. *
  481. * ```php
  482. * <?php
  483. * $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
  484. * ```
  485. *
  486. * @param $raw
  487. * @see \Codeception\Module\WebDriver::dontSeeInSource()
  488. */
  489. public function dontSeeInSource($raw) {
  490. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args()));
  491. }
  492. /**
  493. * [!] Method is generated. Documentation taken from corresponding module.
  494. *
  495. * Checks that the page source contains the given string.
  496. *
  497. * ```php
  498. * <?php
  499. * $I->seeInPageSource('<link rel="apple-touch-icon"');
  500. * ```
  501. *
  502. * @param $text
  503. * Conditional Assertion: Test won't be stopped on fail
  504. * @see \Codeception\Module\WebDriver::seeInPageSource()
  505. */
  506. public function canSeeInPageSource($text) {
  507. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPageSource', func_get_args()));
  508. }
  509. /**
  510. * [!] Method is generated. Documentation taken from corresponding module.
  511. *
  512. * Checks that the page source contains the given string.
  513. *
  514. * ```php
  515. * <?php
  516. * $I->seeInPageSource('<link rel="apple-touch-icon"');
  517. * ```
  518. *
  519. * @param $text
  520. * @see \Codeception\Module\WebDriver::seeInPageSource()
  521. */
  522. public function seeInPageSource($text) {
  523. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInPageSource', func_get_args()));
  524. }
  525. /**
  526. * [!] Method is generated. Documentation taken from corresponding module.
  527. *
  528. * Checks that the page source doesn't contain the given string.
  529. *
  530. * @param $text
  531. * Conditional Assertion: Test won't be stopped on fail
  532. * @see \Codeception\Module\WebDriver::dontSeeInPageSource()
  533. */
  534. public function cantSeeInPageSource($text) {
  535. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInPageSource', func_get_args()));
  536. }
  537. /**
  538. * [!] Method is generated. Documentation taken from corresponding module.
  539. *
  540. * Checks that the page source doesn't contain the given string.
  541. *
  542. * @param $text
  543. * @see \Codeception\Module\WebDriver::dontSeeInPageSource()
  544. */
  545. public function dontSeeInPageSource($text) {
  546. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInPageSource', func_get_args()));
  547. }
  548. /**
  549. * [!] Method is generated. Documentation taken from corresponding module.
  550. *
  551. * Perform a click on a link or a button, given by a locator.
  552. * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
  553. * For buttons, the "value" attribute, "name" attribute, and inner text are searched.
  554. * For links, the link text is searched.
  555. * For images, the "alt" attribute and inner text of any parent links are searched.
  556. *
  557. * The second parameter is a context (CSS or XPath locator) to narrow the search.
  558. *
  559. * Note that if the locator matches a button of type `submit`, the form will be submitted.
  560. *
  561. * ``` php
  562. * <?php
  563. * // simple link
  564. * $I->click('Logout');
  565. * // button of form
  566. * $I->click('Submit');
  567. * // CSS button
  568. * $I->click('#form input[type=submit]');
  569. * // XPath
  570. * $I->click('//form/*[@type=submit]');
  571. * // link in context
  572. * $I->click('Logout', '#nav');
  573. * // using strict locator
  574. * $I->click(['link' => 'Login']);
  575. * ?>
  576. * ```
  577. *
  578. * @param $link
  579. * @param $context
  580. * @see \Codeception\Module\WebDriver::click()
  581. */
  582. public function click($link, $context = null) {
  583. return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args()));
  584. }
  585. /**
  586. * [!] Method is generated. Documentation taken from corresponding module.
  587. *
  588. * Checks that there's a link with the specified text.
  589. * Give a full URL as the second parameter to match links with that exact URL.
  590. *
  591. * ``` php
  592. * <?php
  593. * $I->seeLink('Logout'); // matches <a href="#">Logout</a>
  594. * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
  595. * ?>
  596. * ```
  597. *
  598. * @param string $text
  599. * @param string $url optional
  600. * Conditional Assertion: Test won't be stopped on fail
  601. * @see \Codeception\Module\WebDriver::seeLink()
  602. */
  603. public function canSeeLink($text, $url = null) {
  604. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
  605. }
  606. /**
  607. * [!] Method is generated. Documentation taken from corresponding module.
  608. *
  609. * Checks that there's a link with the specified text.
  610. * Give a full URL as the second parameter to match links with that exact URL.
  611. *
  612. * ``` php
  613. * <?php
  614. * $I->seeLink('Logout'); // matches <a href="#">Logout</a>
  615. * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
  616. * ?>
  617. * ```
  618. *
  619. * @param string $text
  620. * @param string $url optional
  621. * @see \Codeception\Module\WebDriver::seeLink()
  622. */
  623. public function seeLink($text, $url = null) {
  624. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
  625. }
  626. /**
  627. * [!] Method is generated. Documentation taken from corresponding module.
  628. *
  629. * Checks that the page doesn't contain a link with the given string.
  630. * If the second parameter is given, only links with a matching "href" attribute will be checked.
  631. *
  632. * ``` php
  633. * <?php
  634. * $I->dontSeeLink('Logout'); // I suppose user is not logged in
  635. * $I->dontSeeLink('Checkout now', '/store/cart.php');
  636. * ?>
  637. * ```
  638. *
  639. * @param string $text
  640. * @param string $url optional
  641. * Conditional Assertion: Test won't be stopped on fail
  642. * @see \Codeception\Module\WebDriver::dontSeeLink()
  643. */
  644. public function cantSeeLink($text, $url = null) {
  645. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
  646. }
  647. /**
  648. * [!] Method is generated. Documentation taken from corresponding module.
  649. *
  650. * Checks that the page doesn't contain a link with the given string.
  651. * If the second parameter is given, only links with a matching "href" attribute will be checked.
  652. *
  653. * ``` php
  654. * <?php
  655. * $I->dontSeeLink('Logout'); // I suppose user is not logged in
  656. * $I->dontSeeLink('Checkout now', '/store/cart.php');
  657. * ?>
  658. * ```
  659. *
  660. * @param string $text
  661. * @param string $url optional
  662. * @see \Codeception\Module\WebDriver::dontSeeLink()
  663. */
  664. public function dontSeeLink($text, $url = null) {
  665. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args()));
  666. }
  667. /**
  668. * [!] Method is generated. Documentation taken from corresponding module.
  669. *
  670. * Checks that current URI contains the given string.
  671. *
  672. * ``` php
  673. * <?php
  674. * // to match: /home/dashboard
  675. * $I->seeInCurrentUrl('home');
  676. * // to match: /users/1
  677. * $I->seeInCurrentUrl('/users/');
  678. * ?>
  679. * ```
  680. *
  681. * @param string $uri
  682. * Conditional Assertion: Test won't be stopped on fail
  683. * @see \Codeception\Module\WebDriver::seeInCurrentUrl()
  684. */
  685. public function canSeeInCurrentUrl($uri) {
  686. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
  687. }
  688. /**
  689. * [!] Method is generated. Documentation taken from corresponding module.
  690. *
  691. * Checks that current URI contains the given string.
  692. *
  693. * ``` php
  694. * <?php
  695. * // to match: /home/dashboard
  696. * $I->seeInCurrentUrl('home');
  697. * // to match: /users/1
  698. * $I->seeInCurrentUrl('/users/');
  699. * ?>
  700. * ```
  701. *
  702. * @param string $uri
  703. * @see \Codeception\Module\WebDriver::seeInCurrentUrl()
  704. */
  705. public function seeInCurrentUrl($uri) {
  706. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
  707. }
  708. /**
  709. * [!] Method is generated. Documentation taken from corresponding module.
  710. *
  711. * Checks that the current URL is equal to the given string.
  712. * Unlike `seeInCurrentUrl`, this only matches the full URL.
  713. *
  714. * ``` php
  715. * <?php
  716. * // to match root url
  717. * $I->seeCurrentUrlEquals('/');
  718. * ?>
  719. * ```
  720. *
  721. * @param string $uri
  722. * Conditional Assertion: Test won't be stopped on fail
  723. * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals()
  724. */
  725. public function canSeeCurrentUrlEquals($uri) {
  726. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
  727. }
  728. /**
  729. * [!] Method is generated. Documentation taken from corresponding module.
  730. *
  731. * Checks that the current URL is equal to the given string.
  732. * Unlike `seeInCurrentUrl`, this only matches the full URL.
  733. *
  734. * ``` php
  735. * <?php
  736. * // to match root url
  737. * $I->seeCurrentUrlEquals('/');
  738. * ?>
  739. * ```
  740. *
  741. * @param string $uri
  742. * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals()
  743. */
  744. public function seeCurrentUrlEquals($uri) {
  745. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
  746. }
  747. /**
  748. * [!] Method is generated. Documentation taken from corresponding module.
  749. *
  750. * Checks that the current URL matches the given regular expression.
  751. *
  752. * ``` php
  753. * <?php
  754. * // to match root url
  755. * $I->seeCurrentUrlMatches('~$/users/(\d+)~');
  756. * ?>
  757. * ```
  758. *
  759. * @param string $uri
  760. * Conditional Assertion: Test won't be stopped on fail
  761. * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches()
  762. */
  763. public function canSeeCurrentUrlMatches($uri) {
  764. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
  765. }
  766. /**
  767. * [!] Method is generated. Documentation taken from corresponding module.
  768. *
  769. * Checks that the current URL matches the given regular expression.
  770. *
  771. * ``` php
  772. * <?php
  773. * // to match root url
  774. * $I->seeCurrentUrlMatches('~$/users/(\d+)~');
  775. * ?>
  776. * ```
  777. *
  778. * @param string $uri
  779. * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches()
  780. */
  781. public function seeCurrentUrlMatches($uri) {
  782. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
  783. }
  784. /**
  785. * [!] Method is generated. Documentation taken from corresponding module.
  786. *
  787. * Checks that the current URI doesn't contain the given string.
  788. *
  789. * ``` php
  790. * <?php
  791. * $I->dontSeeInCurrentUrl('/users/');
  792. * ?>
  793. * ```
  794. *
  795. * @param string $uri
  796. * Conditional Assertion: Test won't be stopped on fail
  797. * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl()
  798. */
  799. public function cantSeeInCurrentUrl($uri) {
  800. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
  801. }
  802. /**
  803. * [!] Method is generated. Documentation taken from corresponding module.
  804. *
  805. * Checks that the current URI doesn't contain the given string.
  806. *
  807. * ``` php
  808. * <?php
  809. * $I->dontSeeInCurrentUrl('/users/');
  810. * ?>
  811. * ```
  812. *
  813. * @param string $uri
  814. * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl()
  815. */
  816. public function dontSeeInCurrentUrl($uri) {
  817. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args()));
  818. }
  819. /**
  820. * [!] Method is generated. Documentation taken from corresponding module.
  821. *
  822. * Checks that the current URL doesn't equal the given string.
  823. * Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
  824. *
  825. * ``` php
  826. * <?php
  827. * // current url is not root
  828. * $I->dontSeeCurrentUrlEquals('/');
  829. * ?>
  830. * ```
  831. *
  832. * @param string $uri
  833. * Conditional Assertion: Test won't be stopped on fail
  834. * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals()
  835. */
  836. public function cantSeeCurrentUrlEquals($uri) {
  837. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
  838. }
  839. /**
  840. * [!] Method is generated. Documentation taken from corresponding module.
  841. *
  842. * Checks that the current URL doesn't equal the given string.
  843. * Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
  844. *
  845. * ``` php
  846. * <?php
  847. * // current url is not root
  848. * $I->dontSeeCurrentUrlEquals('/');
  849. * ?>
  850. * ```
  851. *
  852. * @param string $uri
  853. * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals()
  854. */
  855. public function dontSeeCurrentUrlEquals($uri) {
  856. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args()));
  857. }
  858. /**
  859. * [!] Method is generated. Documentation taken from corresponding module.
  860. *
  861. * Checks that current url doesn't match the given regular expression.
  862. *
  863. * ``` php
  864. * <?php
  865. * // to match root url
  866. * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
  867. * ?>
  868. * ```
  869. *
  870. * @param string $uri
  871. * Conditional Assertion: Test won't be stopped on fail
  872. * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches()
  873. */
  874. public function cantSeeCurrentUrlMatches($uri) {
  875. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
  876. }
  877. /**
  878. * [!] Method is generated. Documentation taken from corresponding module.
  879. *
  880. * Checks that current url doesn't match the given regular expression.
  881. *
  882. * ``` php
  883. * <?php
  884. * // to match root url
  885. * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~');
  886. * ?>
  887. * ```
  888. *
  889. * @param string $uri
  890. * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches()
  891. */
  892. public function dontSeeCurrentUrlMatches($uri) {
  893. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args()));
  894. }
  895. /**
  896. * [!] Method is generated. Documentation taken from corresponding module.
  897. *
  898. * Executes the given regular expression against the current URI and returns the first match.
  899. * If no parameters are provided, the full URI is returned.
  900. *
  901. * ``` php
  902. * <?php
  903. * $user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~');
  904. * $uri = $I->grabFromCurrentUrl();
  905. * ?>
  906. * ```
  907. *
  908. * @param string $uri optional
  909. *
  910. * @return mixed
  911. * @see \Codeception\Module\WebDriver::grabFromCurrentUrl()
  912. */
  913. public function grabFromCurrentUrl($uri = null) {
  914. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
  915. }
  916. /**
  917. * [!] Method is generated. Documentation taken from corresponding module.
  918. *
  919. * Checks that the specified checkbox is checked.
  920. *
  921. * ``` php
  922. * <?php
  923. * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
  924. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
  925. * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
  926. * ?>
  927. * ```
  928. *
  929. * @param $checkbox
  930. * Conditional Assertion: Test won't be stopped on fail
  931. * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked()
  932. */
  933. public function canSeeCheckboxIsChecked($checkbox) {
  934. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
  935. }
  936. /**
  937. * [!] Method is generated. Documentation taken from corresponding module.
  938. *
  939. * Checks that the specified checkbox is checked.
  940. *
  941. * ``` php
  942. * <?php
  943. * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
  944. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
  945. * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
  946. * ?>
  947. * ```
  948. *
  949. * @param $checkbox
  950. * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked()
  951. */
  952. public function seeCheckboxIsChecked($checkbox) {
  953. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
  954. }
  955. /**
  956. * [!] Method is generated. Documentation taken from corresponding module.
  957. *
  958. * Check that the specified checkbox is unchecked.
  959. *
  960. * ``` php
  961. * <?php
  962. * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
  963. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
  964. * ?>
  965. * ```
  966. *
  967. * @param $checkbox
  968. * Conditional Assertion: Test won't be stopped on fail
  969. * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked()
  970. */
  971. public function cantSeeCheckboxIsChecked($checkbox) {
  972. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
  973. }
  974. /**
  975. * [!] Method is generated. Documentation taken from corresponding module.
  976. *
  977. * Check that the specified checkbox is unchecked.
  978. *
  979. * ``` php
  980. * <?php
  981. * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
  982. * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
  983. * ?>
  984. * ```
  985. *
  986. * @param $checkbox
  987. * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked()
  988. */
  989. public function dontSeeCheckboxIsChecked($checkbox) {
  990. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args()));
  991. }
  992. /**
  993. * [!] Method is generated. Documentation taken from corresponding module.
  994. *
  995. * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
  996. * Fields are matched by label text, the "name" attribute, CSS, or XPath.
  997. *
  998. * ``` php
  999. * <?php
  1000. * $I->seeInField('Body','Type your comment here');
  1001. * $I->seeInField('form textarea[name=body]','Type your comment here');
  1002. * $I->seeInField('form input[type=hidden]','hidden_value');
  1003. * $I->seeInField('#searchform input','Search');
  1004. * $I->seeInField('//form/*[@name=search]','Search');
  1005. * $I->seeInField(['name' => 'search'], 'Search');
  1006. * ?>
  1007. * ```
  1008. *
  1009. * @param $field
  1010. * @param $value
  1011. * Conditional Assertion: Test won't be stopped on fail
  1012. * @see \Codeception\Module\WebDriver::seeInField()
  1013. */
  1014. public function canSeeInField($field, $value) {
  1015. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
  1016. }
  1017. /**
  1018. * [!] Method is generated. Documentation taken from corresponding module.
  1019. *
  1020. * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
  1021. * Fields are matched by label text, the "name" attribute, CSS, or XPath.
  1022. *
  1023. * ``` php
  1024. * <?php
  1025. * $I->seeInField('Body','Type your comment here');
  1026. * $I->seeInField('form textarea[name=body]','Type your comment here');
  1027. * $I->seeInField('form input[type=hidden]','hidden_value');
  1028. * $I->seeInField('#searchform input','Search');
  1029. * $I->seeInField('//form/*[@name=search]','Search');
  1030. * $I->seeInField(['name' => 'search'], 'Search');
  1031. * ?>
  1032. * ```
  1033. *
  1034. * @param $field
  1035. * @param $value
  1036. * @see \Codeception\Module\WebDriver::seeInField()
  1037. */
  1038. public function seeInField($field, $value) {
  1039. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
  1040. }
  1041. /**
  1042. * [!] Method is generated. Documentation taken from corresponding module.
  1043. *
  1044. * Checks that an input field or textarea doesn't contain the given value.
  1045. * For fuzzy locators, the field is matched by label text, CSS and XPath.
  1046. *
  1047. * ``` php
  1048. * <?php
  1049. * $I->dontSeeInField('Body','Type your comment here');
  1050. * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
  1051. * $I->dontSeeInField('form input[type=hidden]','hidden_value');
  1052. * $I->dontSeeInField('#searchform input','Search');
  1053. * $I->dontSeeInField('//form/*[@name=search]','Search');
  1054. * $I->dontSeeInField(['name' => 'search'], 'Search');
  1055. * ?>
  1056. * ```
  1057. *
  1058. * @param $field
  1059. * @param $value
  1060. * Conditional Assertion: Test won't be stopped on fail
  1061. * @see \Codeception\Module\WebDriver::dontSeeInField()
  1062. */
  1063. public function cantSeeInField($field, $value) {
  1064. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args()));
  1065. }
  1066. /**
  1067. * [!] Method is generated. Documentation taken from corresponding module.
  1068. *
  1069. * Checks that an input field or textarea doesn't contain the given value.
  1070. * For fuzzy locators, the field is matched by label text, CSS and XPath.
  1071. *
  1072. * ``` php
  1073. * <?php
  1074. * $I->dontSeeInField('Body','Type your comment here');
  1075. * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
  1076. * $I->dontSeeInField('form input[type=hidden]','hidden_value');
  1077. * $I->dontSeeInField('#searchform input','Search');
  1078. * $I->dontSeeInField('//form/*[@name=search]','Search');
  1079. * $I->dontSeeInField(['name' => 'search'], 'Search');
  1080. * ?>
  1081. * ```
  1082. *
  1083. * @param $field
  1084. * @param $value
  1085. * @see \Codeception\Module\WebDriver::dontSeeInField()
  1086. */
  1087. public function dontSeeInField($field, $value) {
  1088. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args()));
  1089. }
  1090. /**
  1091. * [!] Method is generated. Documentation taken from corresponding module.
  1092. *
  1093. * Checks if the array of form parameters (name => value) are set on the form matched with the
  1094. * passed selector.
  1095. *
  1096. * ``` php
  1097. * <?php
  1098. * $I->seeInFormFields('form[name=myform]', [
  1099. * 'input1' => 'value',
  1100. * 'input2' => 'other value',
  1101. * ]);
  1102. * ?>
  1103. * ```
  1104. *
  1105. * For multi-select elements, or to check values of multiple elements with the same name, an
  1106. * array may be passed:
  1107. *
  1108. * ``` php
  1109. * <?php
  1110. * $I->seeInFormFields('.form-class', [
  1111. * 'multiselect' => [
  1112. * 'value1',
  1113. * 'value2',
  1114. * ],
  1115. * 'checkbox[]' => [
  1116. * 'a checked value',
  1117. * 'another checked value',
  1118. * ],
  1119. * ]);
  1120. * ?>
  1121. * ```
  1122. *
  1123. * Additionally, checkbox values can be checked with a boolean.
  1124. *
  1125. * ``` php
  1126. * <?php
  1127. * $I->seeInFormFields('#form-id', [
  1128. * 'checkbox1' => true, // passes if checked
  1129. * 'checkbox2' => false, // passes if unchecked
  1130. * ]);
  1131. * ?>
  1132. * ```
  1133. *
  1134. * Pair this with submitForm for quick testing magic.
  1135. *
  1136. * ``` php
  1137. * <?php
  1138. * $form = [
  1139. * 'field1' => 'value',
  1140. * 'field2' => 'another value',
  1141. * 'checkbox1' => true,
  1142. * // ...
  1143. * ];
  1144. * $I->submitForm('//form[@id=my-form]', $form, 'submitButton');
  1145. * // $I->amOnPage('/path/to/form-page') may be needed
  1146. * $I->seeInFormFields('//form[@id=my-form]', $form);
  1147. * ?>
  1148. * ```
  1149. *
  1150. * @param $formSelector
  1151. * @param $params
  1152. * Conditional Assertion: Test won't be stopped on fail
  1153. * @see \Codeception\Module\WebDriver::seeInFormFields()
  1154. */
  1155. public function canSeeInFormFields($formSelector, $params) {
  1156. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args()));
  1157. }
  1158. /**
  1159. * [!] Method is generated. Documentation taken from corresponding module.
  1160. *
  1161. * Checks if the array of form parameters (name => value) are set on the form matched with the
  1162. * passed selector.
  1163. *
  1164. * ``` php
  1165. * <?php
  1166. * $I->seeInFormFields('form[name=myform]', [
  1167. * 'input1' => 'value',
  1168. * 'input2' => 'other value',
  1169. * ]);
  1170. * ?>
  1171. * ```
  1172. *
  1173. * For multi-select elements, or to check values of multiple elements with the same name, an
  1174. * array may be passed:
  1175. *
  1176. * ``` php
  1177. * <?php
  1178. * $I->seeInFormFields('.form-class', [
  1179. * 'multiselect' => [
  1180. * 'value1',
  1181. * 'value2',
  1182. * ],
  1183. * 'checkbox[]' => [
  1184. * 'a checked value',
  1185. * 'another checked value',
  1186. * ],
  1187. * ]);
  1188. * ?>
  1189. * ```
  1190. *
  1191. * Additionally, checkbox values can be checked with a boolean.
  1192. *
  1193. * ``` php
  1194. * <?php
  1195. * $I->seeInFormFields('#form-id', [
  1196. * 'checkbox1' => true, // passes if checked
  1197. * 'checkbox2' => false, // passes if unchecked
  1198. * ]);
  1199. * ?>
  1200. * ```
  1201. *
  1202. * Pair this with submitForm for quick testing magic.
  1203. *
  1204. * ``` php
  1205. * <?php
  1206. * $form = [
  1207. * 'field1' => 'value',
  1208. * 'field2' => 'another value',
  1209. * 'checkbox1' => true,
  1210. * // ...
  1211. * ];
  1212. * $I->submitForm('//form[@id=my-form]', $form, 'submitButton');
  1213. * // $I->amOnPage('/path/to/form-page') may be needed
  1214. * $I->seeInFormFields('//form[@id=my-form]', $form);
  1215. * ?>
  1216. * ```
  1217. *
  1218. * @param $formSelector
  1219. * @param $params
  1220. * @see \Codeception\Module\WebDriver::seeInFormFields()
  1221. */
  1222. public function seeInFormFields($formSelector, $params) {
  1223. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args()));
  1224. }
  1225. /**
  1226. * [!] Method is generated. Documentation taken from corresponding module.
  1227. *
  1228. * Checks if the array of form parameters (name => value) are not set on the form matched with
  1229. * the passed selector.
  1230. *
  1231. * ``` php
  1232. * <?php
  1233. * $I->dontSeeInFormFields('form[name=myform]', [
  1234. * 'input1' => 'non-existent value',
  1235. * 'input2' => 'other non-existent value',
  1236. * ]);
  1237. * ?>
  1238. * ```
  1239. *
  1240. * To check that an element hasn't been assigned any one of many values, an array can be passed
  1241. * as the value:
  1242. *
  1243. * ``` php
  1244. * <?php
  1245. * $I->dontSeeInFormFields('.form-class', [
  1246. * 'fieldName' => [
  1247. * 'This value shouldn\'t be set',
  1248. * 'And this value shouldn\'t be set',
  1249. * ],
  1250. * ]);
  1251. * ?>
  1252. * ```
  1253. *
  1254. * Additionally, checkbox values can be checked with a boolean.
  1255. *
  1256. * ``` php
  1257. * <?php
  1258. * $I->dontSeeInFormFields('#form-id', [
  1259. * 'checkbox1' => true, // fails if checked
  1260. * 'checkbox2' => false, // fails if unchecked
  1261. * ]);
  1262. * ?>
  1263. * ```
  1264. *
  1265. * @param $formSelector
  1266. * @param $params
  1267. * Conditional Assertion: Test won't be stopped on fail
  1268. * @see \Codeception\Module\WebDriver::dontSeeInFormFields()
  1269. */
  1270. public function cantSeeInFormFields($formSelector, $params) {
  1271. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args()));
  1272. }
  1273. /**
  1274. * [!] Method is generated. Documentation taken from corresponding module.
  1275. *
  1276. * Checks if the array of form parameters (name => value) are not set on the form matched with
  1277. * the passed selector.
  1278. *
  1279. * ``` php
  1280. * <?php
  1281. * $I->dontSeeInFormFields('form[name=myform]', [
  1282. * 'input1' => 'non-existent value',
  1283. * 'input2' => 'other non-existent value',
  1284. * ]);
  1285. * ?>
  1286. * ```
  1287. *
  1288. * To check that an element hasn't been assigned any one of many values, an array can be passed
  1289. * as the value:
  1290. *
  1291. * ``` php
  1292. * <?php
  1293. * $I->dontSeeInFormFields('.form-class', [
  1294. * 'fieldName' => [
  1295. * 'This value shouldn\'t be set',
  1296. * 'And this value shouldn\'t be set',
  1297. * ],
  1298. * ]);
  1299. * ?>
  1300. * ```
  1301. *
  1302. * Additionally, checkbox values can be checked with a boolean.
  1303. *
  1304. * ``` php
  1305. * <?php
  1306. * $I->dontSeeInFormFields('#form-id', [
  1307. * 'checkbox1' => true, // fails if checked
  1308. * 'checkbox2' => false, // fails if unchecked
  1309. * ]);
  1310. * ?>
  1311. * ```
  1312. *
  1313. * @param $formSelector
  1314. * @param $params
  1315. * @see \Codeception\Module\WebDriver::dontSeeInFormFields()
  1316. */
  1317. public function dontSeeInFormFields($formSelector, $params) {
  1318. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args()));
  1319. }
  1320. /**
  1321. * [!] Method is generated. Documentation taken from corresponding module.
  1322. *
  1323. * Selects an option in a select tag or in radio button group.
  1324. *
  1325. * ``` php
  1326. * <?php
  1327. * $I->selectOption('form select[name=account]', 'Premium');
  1328. * $I->selectOption('form input[name=payment]', 'Monthly');
  1329. * $I->selectOption('//form/select[@name=account]', 'Monthly');
  1330. * ?>
  1331. * ```
  1332. *
  1333. * Provide an array for the second argument to select multiple options:
  1334. *
  1335. * ``` php
  1336. * <?php
  1337. * $I->selectOption('Which OS do you use?', array('Windows','Linux'));
  1338. * ?>
  1339. * ```
  1340. *
  1341. * Or provide an associative array for the second argument to specifically define which selection method should be used:
  1342. *
  1343. * ``` php
  1344. * <?php
  1345. * $I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows'
  1346. * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows'
  1347. * ?>
  1348. * ```
  1349. *
  1350. * @param $select
  1351. * @param $option
  1352. * @see \Codeception\Module\WebDriver::selectOption()
  1353. */
  1354. public function selectOption($select, $option) {
  1355. return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args()));
  1356. }
  1357. /**
  1358. * [!] Method is generated. Documentation taken from corresponding module.
  1359. *
  1360. * Unselect an option in the given select box.
  1361. *
  1362. * @param $select
  1363. * @param $option
  1364. * @see \Codeception\Module\WebDriver::unselectOption()
  1365. */
  1366. public function unselectOption($select, $option) {
  1367. return $this->getScenario()->runStep(new \Codeception\Step\Action('unselectOption', func_get_args()));
  1368. }
  1369. /**
  1370. * [!] Method is generated. Documentation taken from corresponding module.
  1371. *
  1372. * Ticks a checkbox. For radio buttons, use the `selectOption` method instead.
  1373. *
  1374. * ``` php
  1375. * <?php
  1376. * $I->checkOption('#agree');
  1377. * ?>
  1378. * ```
  1379. *
  1380. * @param $option
  1381. * @see \Codeception\Module\WebDriver::checkOption()
  1382. */
  1383. public function checkOption($option) {
  1384. return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args()));
  1385. }
  1386. /**
  1387. * [!] Method is generated. Documentation taken from corresponding module.
  1388. *
  1389. * Unticks a checkbox.
  1390. *
  1391. * ``` php
  1392. * <?php
  1393. * $I->uncheckOption('#notify');
  1394. * ?>
  1395. * ```
  1396. *
  1397. * @param $option
  1398. * @see \Codeception\Module\WebDriver::uncheckOption()
  1399. */
  1400. public function uncheckOption($option) {
  1401. return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args()));
  1402. }
  1403. /**
  1404. * [!] Method is generated. Documentation taken from corresponding module.
  1405. *
  1406. * Fills a text field or textarea with the given string.
  1407. *
  1408. * ``` php
  1409. * <?php
  1410. * $I->fillField("//input[@type='text']", "Hello World!");
  1411. * $I->fillField(['name' => 'email'], 'jon@mail.com');
  1412. * ?>
  1413. * ```
  1414. *
  1415. * @param $field
  1416. * @param $value
  1417. * @see \Codeception\Module\WebDriver::fillField()
  1418. */
  1419. public function fillField($field, $value) {
  1420. return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args()));
  1421. }
  1422. /**
  1423. * [!] Method is generated. Documentation taken from corresponding module.
  1424. *
  1425. * Attaches a file relative to the Codeception `_data` directory to the given file upload field.
  1426. *
  1427. * ``` php
  1428. * <?php
  1429. * // file is stored in 'tests/_data/prices.xls'
  1430. * $I->attachFile('input[@type="file"]', 'prices.xls');
  1431. * ?>
  1432. * ```
  1433. *
  1434. * @param $field
  1435. * @param $filename
  1436. * @see \Codeception\Module\WebDriver::attachFile()
  1437. */
  1438. public function attachFile($field, $filename) {
  1439. return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args()));
  1440. }
  1441. /**
  1442. * [!] Method is generated. Documentation taken from corresponding module.
  1443. *
  1444. * Finds and returns the text contents of the given element.
  1445. * If a fuzzy locator is used, the element is found using CSS, XPath,
  1446. * and by matching the full page source by regular expression.
  1447. *
  1448. * ``` php
  1449. * <?php
  1450. * $heading = $I->grabTextFrom('h1');
  1451. * $heading = $I->grabTextFrom('descendant-or-self::h1');
  1452. * $value = $I->grabTextFrom('~<input value=(.*?)]~sgi'); // match with a regex
  1453. * ?>
  1454. * ```
  1455. *
  1456. * @param $cssOrXPathOrRegex
  1457. *
  1458. * @return mixed
  1459. * @see \Codeception\Module\WebDriver::grabTextFrom()
  1460. */
  1461. public function grabTextFrom($cssOrXPathOrRegex) {
  1462. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args()));
  1463. }
  1464. /**
  1465. * [!] Method is generated. Documentation taken from corresponding module.
  1466. *
  1467. * Grabs the value of the given attribute value from the given element.
  1468. * Fails if element is not found.
  1469. *
  1470. * ``` php
  1471. * <?php
  1472. * $I->grabAttributeFrom('#tooltip', 'title');
  1473. * ?>
  1474. * ```
  1475. *
  1476. *
  1477. * @param $cssOrXpath
  1478. * @param $attribute
  1479. *
  1480. * @return mixed
  1481. * @see \Codeception\Module\WebDriver::grabAttributeFrom()
  1482. */
  1483. public function grabAttributeFrom($cssOrXpath, $attribute) {
  1484. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args()));
  1485. }
  1486. /**
  1487. * [!] Method is generated. Documentation taken from corresponding module.
  1488. *
  1489. * Finds the value for the given form field.
  1490. * If a fuzzy locator is used, the field is found by field name, CSS, and XPath.
  1491. *
  1492. * ``` php
  1493. * <?php
  1494. * $name = $I->grabValueFrom('Name');
  1495. * $name = $I->grabValueFrom('input[name=username]');
  1496. * $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']');
  1497. * $name = $I->grabValueFrom(['name' => 'username']);
  1498. * ?>
  1499. * ```
  1500. *
  1501. * @param $field
  1502. *
  1503. * @return mixed
  1504. * @see \Codeception\Module\WebDriver::grabValueFrom()
  1505. */
  1506. public function grabValueFrom($field) {
  1507. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args()));
  1508. }
  1509. /**
  1510. * [!] Method is generated. Documentation taken from corresponding module.
  1511. *
  1512. * Grabs either the text content, or attribute values, of nodes
  1513. * matched by $cssOrXpath and returns them as an array.
  1514. *
  1515. * ```html
  1516. * <a href="#first">First</a>
  1517. * <a href="#second">Second</a>
  1518. * <a href="#third">Third</a>
  1519. * ```
  1520. *
  1521. * ```php
  1522. * <?php
  1523. * // would return ['First', 'Second', 'Third']
  1524. * $aLinkText = $I->grabMultiple('a');
  1525. *
  1526. * // would return ['#first', '#second', '#third']
  1527. * $aLinks = $I->grabMultiple('a', 'href');
  1528. * ?>
  1529. * ```
  1530. *
  1531. * @param $cssOrXpath
  1532. * @param $attribute
  1533. * @return string[]
  1534. * @see \Codeception\Module\WebDriver::grabMultiple()
  1535. */
  1536. public function grabMultiple($cssOrXpath, $attribute = null) {
  1537. return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args()));
  1538. }
  1539. /**
  1540. * [!] Method is generated. Documentation taken from corresponding module.
  1541. *
  1542. * Checks that the given element exists on the page and is visible.
  1543. * You can also specify expected attributes of this element.
  1544. *
  1545. * ``` php
  1546. * <?php
  1547. * $I->seeElement('.error');
  1548. * $I->seeElement('//form/input[1]');
  1549. * $I->seeElement('input', ['name' => 'login']);
  1550. * $I->seeElement('input', ['value' => '123456']);
  1551. *
  1552. * // strict locator in first arg, attributes in second
  1553. * $I->seeElement(['css' => 'form input'], ['name' => 'login']);
  1554. * ?>
  1555. * ```
  1556. *
  1557. * @param $selector
  1558. * @param array $attributes
  1559. * @return
  1560. * Conditional Assertion: Test won't be stopped on fail
  1561. * @see \Codeception\Module\WebDriver::seeElement()
  1562. */
  1563. public function canSeeElement($selector, $attributes = null) {
  1564. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args()));
  1565. }
  1566. /**
  1567. * [!] Method is generated. Documentation taken from corresponding module.
  1568. *
  1569. * Checks that the given element exists on the page and is visible.
  1570. * You can also specify expected attributes of this element.
  1571. *
  1572. * ``` php
  1573. * <?php
  1574. * $I->seeElement('.error');
  1575. * $I->seeElement('//form/input[1]');
  1576. * $I->seeElement('input', ['name' => 'login']);
  1577. * $I->seeElement('input', ['value' => '123456']);
  1578. *
  1579. * // strict locator in first arg, attributes in second
  1580. * $I->seeElement(['css' => 'form input'], ['name' => 'login']);
  1581. * ?>
  1582. * ```
  1583. *
  1584. * @param $selector
  1585. * @param array $attributes
  1586. * @return
  1587. * @see \Codeception\Module\WebDriver::seeElement()
  1588. */
  1589. public function seeElement($selector, $attributes = null) {
  1590. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args()));
  1591. }
  1592. /**
  1593. * [!] Method is generated. Documentation taken from corresponding module.
  1594. *
  1595. * Checks that the given element is invisible or not present on the page.
  1596. * You can also specify expected attributes of this element.
  1597. *
  1598. * ``` php
  1599. * <?php
  1600. * $I->dontSeeElement('.error');
  1601. * $I->dontSeeElement('//form/input[1]');
  1602. * $I->dontSeeElement('input', ['name' => 'login']);
  1603. * $I->dontSeeElement('input', ['value' => '123456']);
  1604. * ?>
  1605. * ```
  1606. *
  1607. * @param $selector
  1608. * @param array $attributes
  1609. * Conditional Assertion: Test won't be stopped on fail
  1610. * @see \Codeception\Module\WebDriver::dontSeeElement()
  1611. */
  1612. public function cantSeeElement($selector, $attributes = null) {
  1613. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args()));
  1614. }
  1615. /**
  1616. * [!] Method is generated. Documentation taken from corresponding module.
  1617. *
  1618. * Checks that the given element is invisible or not present on the page.
  1619. * You can also specify expected attributes of this element.
  1620. *
  1621. * ``` php
  1622. * <?php
  1623. * $I->dontSeeElement('.error');
  1624. * $I->dontSeeElement('//form/input[1]');
  1625. * $I->dontSeeElement('input', ['name' => 'login']);
  1626. * $I->dontSeeElement('input', ['value' => '123456']);
  1627. * ?>
  1628. * ```
  1629. *
  1630. * @param $selector
  1631. * @param array $attributes
  1632. * @see \Codeception\Module\WebDriver::dontSeeElement()
  1633. */
  1634. public function dontSeeElement($selector, $attributes = null) {
  1635. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args()));
  1636. }
  1637. /**
  1638. * [!] Method is generated. Documentation taken from corresponding module.
  1639. *
  1640. * Checks that the given element exists on the page, even it is invisible.
  1641. *
  1642. * ``` php
  1643. * <?php
  1644. * $I->seeElementInDOM('//form/input[type=hidden]');
  1645. * ?>
  1646. * ```
  1647. *
  1648. * @param $selector
  1649. * @param array $attributes
  1650. * Conditional Assertion: Test won't be stopped on fail
  1651. * @see \Codeception\Module\WebDriver::seeElementInDOM()
  1652. */
  1653. public function canSeeElementInDOM($selector, $attributes = null) {
  1654. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElementInDOM', func_get_args()));
  1655. }
  1656. /**
  1657. * [!] Method is generated. Documentation taken from corresponding module.
  1658. *
  1659. * Checks that the given element exists on the page, even it is invisible.
  1660. *
  1661. * ``` php
  1662. * <?php
  1663. * $I->seeElementInDOM('//form/input[type=hidden]');
  1664. * ?>
  1665. * ```
  1666. *
  1667. * @param $selector
  1668. * @param array $attributes
  1669. * @see \Codeception\Module\WebDriver::seeElementInDOM()
  1670. */
  1671. public function seeElementInDOM($selector, $attributes = null) {
  1672. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElementInDOM', func_get_args()));
  1673. }
  1674. /**
  1675. * [!] Method is generated. Documentation taken from corresponding module.
  1676. *
  1677. * Opposite of `seeElementInDOM`.
  1678. *
  1679. * @param $selector
  1680. * @param array $attributes
  1681. * Conditional Assertion: Test won't be stopped on fail
  1682. * @see \Codeception\Module\WebDriver::dontSeeElementInDOM()
  1683. */
  1684. public function cantSeeElementInDOM($selector, $attributes = null) {
  1685. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElementInDOM', func_get_args()));
  1686. }
  1687. /**
  1688. * [!] Method is generated. Documentation taken from corresponding module.
  1689. *
  1690. * Opposite of `seeElementInDOM`.
  1691. *
  1692. * @param $selector
  1693. * @param array $attributes
  1694. * @see \Codeception\Module\WebDriver::dontSeeElementInDOM()
  1695. */
  1696. public function dontSeeElementInDOM($selector, $attributes = null) {
  1697. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElementInDOM', func_get_args()));
  1698. }
  1699. /**
  1700. * [!] Method is generated. Documentation taken from corresponding module.
  1701. *
  1702. * Checks that there are a certain number of elements matched by the given locator on the page.
  1703. *
  1704. * ``` php
  1705. * <?php
  1706. * $I->seeNumberOfElements('tr', 10);
  1707. * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements
  1708. * ?>
  1709. * ```
  1710. * @param $selector
  1711. * @param mixed $expected int or int[]
  1712. * Conditional Assertion: Test won't be stopped on fail
  1713. * @see \Codeception\Module\WebDriver::seeNumberOfElements()
  1714. */
  1715. public function canSeeNumberOfElements($selector, $expected) {
  1716. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args()));
  1717. }
  1718. /**
  1719. * [!] Method is generated. Documentation taken from corresponding module.
  1720. *
  1721. * Checks that there are a certain number of elements matched by the given locator on the page.
  1722. *
  1723. * ``` php
  1724. * <?php
  1725. * $I->seeNumberOfElements('tr', 10);
  1726. * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements
  1727. * ?>
  1728. * ```
  1729. * @param $selector
  1730. * @param mixed $expected int or int[]
  1731. * @see \Codeception\Module\WebDriver::seeNumberOfElements()
  1732. */
  1733. public function seeNumberOfElements($selector, $expected) {
  1734. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args()));
  1735. }
  1736. /**
  1737. * [!] Method is generated. Documentation taken from corresponding module.
  1738. *
  1739. *
  1740. * Conditional Assertion: Test won't be stopped on fail
  1741. * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM()
  1742. */
  1743. public function canSeeNumberOfElementsInDOM($selector, $expected) {
  1744. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElementsInDOM', func_get_args()));
  1745. }
  1746. /**
  1747. * [!] Method is generated. Documentation taken from corresponding module.
  1748. *
  1749. *
  1750. * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM()
  1751. */
  1752. public function seeNumberOfElementsInDOM($selector, $expected) {
  1753. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElementsInDOM', func_get_args()));
  1754. }
  1755. /**
  1756. * [!] Method is generated. Documentation taken from corresponding module.
  1757. *
  1758. * Checks that the given option is selected.
  1759. *
  1760. * ``` php
  1761. * <?php
  1762. * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
  1763. * ?>
  1764. * ```
  1765. *
  1766. * @param $selector
  1767. * @param $optionText
  1768. *
  1769. * @return mixed
  1770. * Conditional Assertion: Test won't be stopped on fail
  1771. * @see \Codeception\Module\WebDriver::seeOptionIsSelected()
  1772. */
  1773. public function canSeeOptionIsSelected($selector, $optionText) {
  1774. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args()));
  1775. }
  1776. /**
  1777. * [!] Method is generated. Documentation taken from corresponding module.
  1778. *
  1779. * Checks that the given option is selected.
  1780. *
  1781. * ``` php
  1782. * <?php
  1783. * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa');
  1784. * ?>
  1785. * ```
  1786. *
  1787. * @param $selector
  1788. * @param $optionText
  1789. *
  1790. * @return mixed
  1791. * @see \Codeception\Module\WebDriver::seeOptionIsSelected()
  1792. */
  1793. public function seeOptionIsSelected($selector, $optionText) {
  1794. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args()));
  1795. }
  1796. /**
  1797. * [!] Method is generated. Documentation taken from corresponding module.
  1798. *
  1799. * Checks that the given option is not selected.
  1800. *
  1801. * ``` php
  1802. * <?php
  1803. * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
  1804. * ?>
  1805. * ```
  1806. *
  1807. * @param $selector
  1808. * @param $optionText
  1809. *
  1810. * @return mixed
  1811. * Conditional Assertion: Test won't be stopped on fail
  1812. * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected()
  1813. */
  1814. public function cantSeeOptionIsSelected($selector, $optionText) {
  1815. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args()));
  1816. }
  1817. /**
  1818. * [!] Method is generated. Documentation taken from corresponding module.
  1819. *
  1820. * Checks that the given option is not selected.
  1821. *
  1822. * ``` php
  1823. * <?php
  1824. * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
  1825. * ?>
  1826. * ```
  1827. *
  1828. * @param $selector
  1829. * @param $optionText
  1830. *
  1831. * @return mixed
  1832. * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected()
  1833. */
  1834. public function dontSeeOptionIsSelected($selector, $optionText) {
  1835. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args()));
  1836. }
  1837. /**
  1838. * [!] Method is generated. Documentation taken from corresponding module.
  1839. *
  1840. * Checks that the page title contains the given string.
  1841. *
  1842. * ``` php
  1843. * <?php
  1844. * $I->seeInTitle('Blog - Post #1');
  1845. * ?>
  1846. * ```
  1847. *
  1848. * @param $title
  1849. *
  1850. * @return mixed
  1851. * Conditional Assertion: Test won't be stopped on fail
  1852. * @see \Codeception\Module\WebDriver::seeInTitle()
  1853. */
  1854. public function canSeeInTitle($title) {
  1855. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args()));
  1856. }
  1857. /**
  1858. * [!] Method is generated. Documentation taken from corresponding module.
  1859. *
  1860. * Checks that the page title contains the given string.
  1861. *
  1862. * ``` php
  1863. * <?php
  1864. * $I->seeInTitle('Blog - Post #1');
  1865. * ?>
  1866. * ```
  1867. *
  1868. * @param $title
  1869. *
  1870. * @return mixed
  1871. * @see \Codeception\Module\WebDriver::seeInTitle()
  1872. */
  1873. public function seeInTitle($title) {
  1874. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args()));
  1875. }
  1876. /**
  1877. * [!] Method is generated. Documentation taken from corresponding module.
  1878. *
  1879. * Checks that the page title does not contain the given string.
  1880. *
  1881. * @param $title
  1882. *
  1883. * @return mixed
  1884. * Conditional Assertion: Test won't be stopped on fail
  1885. * @see \Codeception\Module\WebDriver::dontSeeInTitle()
  1886. */
  1887. public function cantSeeInTitle($title) {
  1888. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args()));
  1889. }
  1890. /**
  1891. * [!] Method is generated. Documentation taken from corresponding module.
  1892. *
  1893. * Checks that the page title does not contain the given string.
  1894. *
  1895. * @param $title
  1896. *
  1897. * @return mixed
  1898. * @see \Codeception\Module\WebDriver::dontSeeInTitle()
  1899. */
  1900. public function dontSeeInTitle($title) {
  1901. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args()));
  1902. }
  1903. /**
  1904. * [!] Method is generated. Documentation taken from corresponding module.
  1905. *
  1906. * Accepts the active JavaScript native popup window, as created by `window.alert`|`window.confirm`|`window.prompt`.
  1907. * Don't confuse popups with modal windows,
  1908. * as created by [various libraries](http://jster.net/category/windows-modals-popups).
  1909. * @see \Codeception\Module\WebDriver::acceptPopup()
  1910. */
  1911. public function acceptPopup() {
  1912. return $this->getScenario()->runStep(new \Codeception\Step\Action('acceptPopup', func_get_args()));
  1913. }
  1914. /**
  1915. * [!] Method is generated. Documentation taken from corresponding module.
  1916. *
  1917. * Dismisses the active JavaScript popup, as created by `window.alert`, `window.confirm`, or `window.prompt`.
  1918. * @see \Codeception\Module\WebDriver::cancelPopup()
  1919. */
  1920. public function cancelPopup() {
  1921. return $this->getScenario()->runStep(new \Codeception\Step\Action('cancelPopup', func_get_args()));
  1922. }
  1923. /**
  1924. * [!] Method is generated. Documentation taken from corresponding module.
  1925. *
  1926. * Checks that the active JavaScript popup,
  1927. * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string.
  1928. *
  1929. * @param $text
  1930. *
  1931. * @throws \Codeception\Exception\ModuleException
  1932. * Conditional Assertion: Test won't be stopped on fail
  1933. * @see \Codeception\Module\WebDriver::seeInPopup()
  1934. */
  1935. public function canSeeInPopup($text) {
  1936. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPopup', func_get_args()));
  1937. }
  1938. /**
  1939. * [!] Method is generated. Documentation taken from corresponding module.
  1940. *
  1941. * Checks that the active JavaScript popup,
  1942. * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string.
  1943. *
  1944. * @param $text
  1945. *
  1946. * @throws \Codeception\Exception\ModuleException
  1947. * @see \Codeception\Module\WebDriver::seeInPopup()
  1948. */
  1949. public function seeInPopup($text) {
  1950. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInPopup', func_get_args()));
  1951. }
  1952. /**
  1953. * [!] Method is generated. Documentation taken from corresponding module.
  1954. *
  1955. * Enters text into a native JavaScript prompt popup, as created by `window.prompt`.
  1956. *
  1957. * @param $keys
  1958. *
  1959. * @throws \Codeception\Exception\ModuleException
  1960. * @see \Codeception\Module\WebDriver::typeInPopup()
  1961. */
  1962. public function typeInPopup($keys) {
  1963. return $this->getScenario()->runStep(new \Codeception\Step\Action('typeInPopup', func_get_args()));
  1964. }
  1965. /**
  1966. * [!] Method is generated. Documentation taken from corresponding module.
  1967. *
  1968. * Reloads the current page.
  1969. * @see \Codeception\Module\WebDriver::reloadPage()
  1970. */
  1971. public function reloadPage() {
  1972. return $this->getScenario()->runStep(new \Codeception\Step\Action('reloadPage', func_get_args()));
  1973. }
  1974. /**
  1975. * [!] Method is generated. Documentation taken from corresponding module.
  1976. *
  1977. * Moves back in history.
  1978. * @see \Codeception\Module\WebDriver::moveBack()
  1979. */
  1980. public function moveBack() {
  1981. return $this->getScenario()->runStep(new \Codeception\Step\Action('moveBack', func_get_args()));
  1982. }
  1983. /**
  1984. * [!] Method is generated. Documentation taken from corresponding module.
  1985. *
  1986. * Moves forward in history.
  1987. * @see \Codeception\Module\WebDriver::moveForward()
  1988. */
  1989. public function moveForward() {
  1990. return $this->getScenario()->runStep(new \Codeception\Step\Action('moveForward', func_get_args()));
  1991. }
  1992. /**
  1993. * [!] Method is generated. Documentation taken from corresponding module.
  1994. *
  1995. * Submits the given form on the page, optionally with the given form
  1996. * values. Give the form fields values as an array. Note that hidden fields
  1997. * can't be accessed.
  1998. *
  1999. * Skipped fields will be filled by their values from the page.
  2000. * You don't need to click the 'Submit' button afterwards.
  2001. * This command itself triggers the request to form's action.
  2002. *
  2003. * You can optionally specify what button's value to include
  2004. * in the request with the last parameter as an alternative to
  2005. * explicitly setting its value in the second parameter, as
  2006. * button values are not otherwise included in the request.
  2007. *
  2008. * Examples:
  2009. *
  2010. * ``` php
  2011. * <?php
  2012. * $I->submitForm('#login', [
  2013. * 'login' => 'davert',
  2014. * 'password' => '123456'
  2015. * ]);
  2016. * // or
  2017. * $I->submitForm('#login', [
  2018. * 'login' => 'davert',
  2019. * 'password' => '123456'
  2020. * ], 'submitButtonName');
  2021. *
  2022. * ```
  2023. *
  2024. * For example, given this sample "Sign Up" form:
  2025. *
  2026. * ``` html
  2027. * <form action="/sign_up">
  2028. * Login:
  2029. * <input type="text" name="user[login]" /><br/>
  2030. * Password:
  2031. * <input type="password" name="user[password]" /><br/>
  2032. * Do you agree to our terms?
  2033. * <input type="checkbox" name="user[agree]" /><br/>
  2034. * Select pricing plan:
  2035. * <select name="plan">
  2036. * <option value="1">Free</option>
  2037. * <option value="2" selected="selected">Paid</option>
  2038. * </select>
  2039. * <input type="submit" name="submitButton" value="Submit" />
  2040. * </form>
  2041. * ```
  2042. *
  2043. * You could write the following to submit it:
  2044. *
  2045. * ``` php
  2046. * <?php
  2047. * $I->submitForm(
  2048. * '#userForm',
  2049. * [
  2050. * 'user[login]' => 'Davert',
  2051. * 'user[password]' => '123456',
  2052. * 'user[agree]' => true
  2053. * ],
  2054. * 'submitButton'
  2055. * );
  2056. * ```
  2057. * Note that "2" will be the submitted value for the "plan" field, as it is
  2058. * the selected option.
  2059. *
  2060. * Also note that this differs from PhpBrowser, in that
  2061. * ```'user' => [ 'login' => 'Davert' ]``` is not supported at the moment.
  2062. * Named array keys *must* be included in the name as above.
  2063. *
  2064. * Pair this with seeInFormFields for quick testing magic.
  2065. *
  2066. * ``` php
  2067. * <?php
  2068. * $form = [
  2069. * 'field1' => 'value',
  2070. * 'field2' => 'another value',
  2071. * 'checkbox1' => true,
  2072. * // ...
  2073. * ];
  2074. * $I->submitForm('//form[@id=my-form]', $form, 'submitButton');
  2075. * // $I->amOnPage('/path/to/form-page') may be needed
  2076. * $I->seeInFormFields('//form[@id=my-form]', $form);
  2077. * ?>
  2078. * ```
  2079. *
  2080. * Parameter values must be set to arrays for multiple input fields
  2081. * of the same name, or multi-select combo boxes. For checkboxes,
  2082. * either the string value can be used, or boolean values which will
  2083. * be replaced by the checkbox's value in the DOM.
  2084. *
  2085. * ``` php
  2086. * <?php
  2087. * $I->submitForm('#my-form', [
  2088. * 'field1' => 'value',
  2089. * 'checkbox' => [
  2090. * 'value of first checkbox',
  2091. * 'value of second checkbox,
  2092. * ],
  2093. * 'otherCheckboxes' => [
  2094. * true,
  2095. * false,
  2096. * false
  2097. * ],
  2098. * 'multiselect' => [
  2099. * 'first option value',
  2100. * 'second option value'
  2101. * ]
  2102. * ]);
  2103. * ?>
  2104. * ```
  2105. *
  2106. * Mixing string and boolean values for a checkbox's value is not supported
  2107. * and may produce unexpected results.
  2108. *
  2109. * Field names ending in "[]" must be passed without the trailing square
  2110. * bracket characters, and must contain an array for its value. This allows
  2111. * submitting multiple values with the same name, consider:
  2112. *
  2113. * ```php
  2114. * $I->submitForm('#my-form', [
  2115. * 'field[]' => 'value',
  2116. * 'field[]' => 'another value', // 'field[]' is already a defined key
  2117. * ]);
  2118. * ```
  2119. *
  2120. * The solution is to pass an array value:
  2121. *
  2122. * ```php
  2123. * // this way both values are submitted
  2124. * $I->submitForm('#my-form', [
  2125. * 'field' => [
  2126. * 'value',
  2127. * 'another value',
  2128. * ]
  2129. * ]);
  2130. * ```
  2131. *
  2132. * The `$button` parameter can be either a string, an array or an instance
  2133. * of Facebook\WebDriver\WebDriverBy. When it is a string, the
  2134. * button will be found by its "name" attribute. If $button is an
  2135. * array then it will be treated as a strict selector and a WebDriverBy
  2136. * will be used verbatim.
  2137. *
  2138. * For example, given the following HTML:
  2139. *
  2140. * ``` html
  2141. * <input type="submit" name="submitButton" value="Submit" />
  2142. * ```
  2143. *
  2144. * `$button` could be any one of the following:
  2145. * - 'submitButton'
  2146. * - ['name' => 'submitButton']
  2147. * - WebDriverBy::name('submitButton')
  2148. *
  2149. * @param $selector
  2150. * @param $params
  2151. * @param $button
  2152. * @see \Codeception\Module\WebDriver::submitForm()
  2153. */
  2154. public function submitForm($selector, $params, $button = null) {
  2155. return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args()));
  2156. }
  2157. /**
  2158. * [!] Method is generated. Documentation taken from corresponding module.
  2159. *
  2160. * Waits up to $timeout seconds for the given element to change.
  2161. * Element "change" is determined by a callback function which is called repeatedly
  2162. * until the return value evaluates to true.
  2163. *
  2164. * ``` php
  2165. * <?php
  2166. * use \Facebook\WebDriver\WebDriverElement
  2167. * $I->waitForElementChange('#menu', function(WebDriverElement $el) {
  2168. * return $el->isDisplayed();
  2169. * }, 100);
  2170. * ?>
  2171. * ```
  2172. *
  2173. * @param $element
  2174. * @param \Closure $callback
  2175. * @param int $timeout seconds
  2176. * @throws \Codeception\Exception\ElementNotFound
  2177. * @see \Codeception\Module\WebDriver::waitForElementChange()
  2178. */
  2179. public function waitForElementChange($element, $callback, $timeout = null) {
  2180. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementChange', func_get_args()));
  2181. }
  2182. /**
  2183. * [!] Method is generated. Documentation taken from corresponding module.
  2184. *
  2185. * Waits up to $timeout seconds for an element to appear on the page.
  2186. * If the element doesn't appear, a timeout exception is thrown.
  2187. *
  2188. * ``` php
  2189. * <?php
  2190. * $I->waitForElement('#agree_button', 30); // secs
  2191. * $I->click('#agree_button');
  2192. * ?>
  2193. * ```
  2194. *
  2195. * @param $element
  2196. * @param int $timeout seconds
  2197. * @throws \Exception
  2198. * @see \Codeception\Module\WebDriver::waitForElement()
  2199. */
  2200. public function waitForElement($element, $timeout = null) {
  2201. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElement', func_get_args()));
  2202. }
  2203. /**
  2204. * [!] Method is generated. Documentation taken from corresponding module.
  2205. *
  2206. * Waits up to $timeout seconds for the given element to be visible on the page.
  2207. * If element doesn't appear, a timeout exception is thrown.
  2208. *
  2209. * ``` php
  2210. * <?php
  2211. * $I->waitForElementVisible('#agree_button', 30); // secs
  2212. * $I->click('#agree_button');
  2213. * ?>
  2214. * ```
  2215. *
  2216. * @param $element
  2217. * @param int $timeout seconds
  2218. * @throws \Exception
  2219. * @see \Codeception\Module\WebDriver::waitForElementVisible()
  2220. */
  2221. public function waitForElementVisible($element, $timeout = null) {
  2222. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementVisible', func_get_args()));
  2223. }
  2224. /**
  2225. * [!] Method is generated. Documentation taken from corresponding module.
  2226. *
  2227. * Waits up to $timeout seconds for the given element to become invisible.
  2228. * If element stays visible, a timeout exception is thrown.
  2229. *
  2230. * ``` php
  2231. * <?php
  2232. * $I->waitForElementNotVisible('#agree_button', 30); // secs
  2233. * ?>
  2234. * ```
  2235. *
  2236. * @param $element
  2237. * @param int $timeout seconds
  2238. * @throws \Exception
  2239. * @see \Codeception\Module\WebDriver::waitForElementNotVisible()
  2240. */
  2241. public function waitForElementNotVisible($element, $timeout = null) {
  2242. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementNotVisible', func_get_args()));
  2243. }
  2244. /**
  2245. * [!] Method is generated. Documentation taken from corresponding module.
  2246. *
  2247. * Waits up to $timeout seconds for the given string to appear on the page.
  2248. *
  2249. * Can also be passed a selector to search in, be as specific as possible when using selectors.
  2250. * waitForText() will only watch the first instance of the matching selector / text provided.
  2251. * If the given text doesn't appear, a timeout exception is thrown.
  2252. *
  2253. * ``` php
  2254. * <?php
  2255. * $I->waitForText('foo', 30); // secs
  2256. * $I->waitForText('foo', 30, '.title'); // secs
  2257. * ?>
  2258. * ```
  2259. *
  2260. * @param string $text
  2261. * @param int $timeout seconds
  2262. * @param string $selector optional
  2263. * @throws \Exception
  2264. * @see \Codeception\Module\WebDriver::waitForText()
  2265. */
  2266. public function waitForText($text, $timeout = null, $selector = null) {
  2267. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForText', func_get_args()));
  2268. }
  2269. /**
  2270. * [!] Method is generated. Documentation taken from corresponding module.
  2271. *
  2272. * Wait for $timeout seconds.
  2273. *
  2274. * @param int $timeout secs
  2275. * @throws \Codeception\Exception\TestRuntimeException
  2276. * @see \Codeception\Module\WebDriver::wait()
  2277. */
  2278. public function wait($timeout) {
  2279. return $this->getScenario()->runStep(new \Codeception\Step\Action('wait', func_get_args()));
  2280. }
  2281. /**
  2282. * [!] Method is generated. Documentation taken from corresponding module.
  2283. *
  2284. * Low-level API method.
  2285. * If Codeception commands are not enough, this allows you to use Selenium WebDriver methods directly:
  2286. *
  2287. * ``` php
  2288. * $I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
  2289. * $webdriver->get('http://google.com');
  2290. * });
  2291. * ```
  2292. *
  2293. * This runs in the context of the
  2294. * [RemoteWebDriver class](https://github.com/facebook/php-webdriver/blob/master/lib/remote/RemoteWebDriver.php).
  2295. * Try not to use this command on a regular basis.
  2296. * If Codeception lacks a feature you need, please implement it and submit a patch.
  2297. *
  2298. * @param callable $function
  2299. * @see \Codeception\Module\WebDriver::executeInSelenium()
  2300. */
  2301. public function executeInSelenium($function) {
  2302. return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInSelenium', func_get_args()));
  2303. }
  2304. /**
  2305. * [!] Method is generated. Documentation taken from corresponding module.
  2306. *
  2307. * Switch to another window identified by name.
  2308. *
  2309. * The window can only be identified by name. If the $name parameter is blank, the parent window will be used.
  2310. *
  2311. * Example:
  2312. * ``` html
  2313. * <input type="button" value="Open window" onclick="window.open('http://example.com', 'another_window')">
  2314. * ```
  2315. *
  2316. * ``` php
  2317. * <?php
  2318. * $I->click("Open window");
  2319. * # switch to another window
  2320. * $I->switchToWindow("another_window");
  2321. * # switch to parent window
  2322. * $I->switchToWindow();
  2323. * ?>
  2324. * ```
  2325. *
  2326. * If the window has no name, match it by switching to next active tab using `switchToNextTab` method.
  2327. *
  2328. * Or use native Selenium functions to get access to all opened windows:
  2329. *
  2330. * ``` php
  2331. * <?php
  2332. * $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
  2333. * $handles=$webdriver->getWindowHandles();
  2334. * $last_window = end($handles);
  2335. * $webdriver->switchTo()->window($last_window);
  2336. * });
  2337. * ?>
  2338. * ```
  2339. *
  2340. * @param string|null $name
  2341. * @see \Codeception\Module\WebDriver::switchToWindow()
  2342. */
  2343. public function switchToWindow($name = null) {
  2344. return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToWindow', func_get_args()));
  2345. }
  2346. /**
  2347. * [!] Method is generated. Documentation taken from corresponding module.
  2348. *
  2349. * Switch to another frame on the page.
  2350. *
  2351. * Example:
  2352. * ``` html
  2353. * <iframe name="another_frame" src="http://example.com">
  2354. *
  2355. * ```
  2356. *
  2357. * ``` php
  2358. * <?php
  2359. * # switch to iframe
  2360. * $I->switchToIFrame("another_frame");
  2361. * # switch to parent page
  2362. * $I->switchToIFrame();
  2363. *
  2364. * ```
  2365. *
  2366. * @param string|null $name
  2367. * @see \Codeception\Module\WebDriver::switchToIFrame()
  2368. */
  2369. public function switchToIFrame($name = null) {
  2370. return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToIFrame', func_get_args()));
  2371. }
  2372. /**
  2373. * [!] Method is generated. Documentation taken from corresponding module.
  2374. *
  2375. * Executes JavaScript and waits up to $timeout seconds for it to return true.
  2376. *
  2377. * In this example we will wait up to 60 seconds for all jQuery AJAX requests to finish.
  2378. *
  2379. * ``` php
  2380. * <?php
  2381. * $I->waitForJS("return $.active == 0;", 60);
  2382. * ?>
  2383. * ```
  2384. *
  2385. * @param string $script
  2386. * @param int $timeout seconds
  2387. * @see \Codeception\Module\WebDriver::waitForJS()
  2388. */
  2389. public function waitForJS($script, $timeout = null) {
  2390. return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForJS', func_get_args()));
  2391. }
  2392. /**
  2393. * [!] Method is generated. Documentation taken from corresponding module.
  2394. *
  2395. * Executes custom JavaScript.
  2396. *
  2397. * This example uses jQuery to get a value and assigns that value to a PHP variable:
  2398. *
  2399. * ```php
  2400. * <?php
  2401. * $myVar = $I->executeJS('return $("#myField").val()');
  2402. * ?>
  2403. * ```
  2404. *
  2405. * @param $script
  2406. * @return mixed
  2407. * @see \Codeception\Module\WebDriver::executeJS()
  2408. */
  2409. public function executeJS($script) {
  2410. return $this->getScenario()->runStep(new \Codeception\Step\Action('executeJS', func_get_args()));
  2411. }
  2412. /**
  2413. * [!] Method is generated. Documentation taken from corresponding module.
  2414. *
  2415. * Maximizes the current window.
  2416. * @see \Codeception\Module\WebDriver::maximizeWindow()
  2417. */
  2418. public function maximizeWindow() {
  2419. return $this->getScenario()->runStep(new \Codeception\Step\Action('maximizeWindow', func_get_args()));
  2420. }
  2421. /**
  2422. * [!] Method is generated. Documentation taken from corresponding module.
  2423. *
  2424. * Performs a simple mouse drag-and-drop operation.
  2425. *
  2426. * ``` php
  2427. * <?php
  2428. * $I->dragAndDrop('#drag', '#drop');
  2429. * ?>
  2430. * ```
  2431. *
  2432. * @param string $source (CSS ID or XPath)
  2433. * @param string $target (CSS ID or XPath)
  2434. * @see \Codeception\Module\WebDriver::dragAndDrop()
  2435. */
  2436. public function dragAndDrop($source, $target) {
  2437. return $this->getScenario()->runStep(new \Codeception\Step\Action('dragAndDrop', func_get_args()));
  2438. }
  2439. /**
  2440. * [!] Method is generated. Documentation taken from corresponding module.
  2441. *
  2442. * Move mouse over the first element matched by the given locator.
  2443. * If the first parameter null then the page is used.
  2444. * If the second and third parameters are given,
  2445. * then the mouse is moved to an offset of the element's top-left corner.
  2446. * Otherwise, the mouse is moved to the center of the element.
  2447. *
  2448. * ``` php
  2449. * <?php
  2450. * $I->moveMouseOver(['css' => '.checkout']);
  2451. * $I->moveMouseOver(null, 20, 50);
  2452. * $I->moveMouseOver(['css' => '.checkout'], 20, 50);
  2453. * ?>
  2454. * ```
  2455. *
  2456. * @param string $cssOrXPath css or xpath of the web element
  2457. * @param int $offsetX
  2458. * @param int $offsetY
  2459. *
  2460. * @throws \Codeception\Exception\ElementNotFound
  2461. * @see \Codeception\Module\WebDriver::moveMouseOver()
  2462. */
  2463. public function moveMouseOver($cssOrXPath = null, $offsetX = null, $offsetY = null) {
  2464. return $this->getScenario()->runStep(new \Codeception\Step\Action('moveMouseOver', func_get_args()));
  2465. }
  2466. /**
  2467. * [!] Method is generated. Documentation taken from corresponding module.
  2468. *
  2469. * Performs click with the left mouse button on an element.
  2470. * If the first parameter `null` then the offset is relative to the actual mouse position.
  2471. * If the second and third parameters are given,
  2472. * then the mouse is moved to an offset of the element's top-left corner.
  2473. * Otherwise, the mouse is moved to the center of the element.
  2474. *
  2475. * ``` php
  2476. * <?php
  2477. * $I->clickWithLeftButton(['css' => '.checkout']);
  2478. * $I->clickWithLeftButton(null, 20, 50);
  2479. * $I->clickWithLeftButton(['css' => '.checkout'], 20, 50);
  2480. * ?>
  2481. * ```
  2482. *
  2483. * @param string $cssOrXPath css or xpath of the web element (body by default).
  2484. * @param int $offsetX
  2485. * @param int $offsetY
  2486. *
  2487. * @throws \Codeception\Exception\ElementNotFound
  2488. * @see \Codeception\Module\WebDriver::clickWithLeftButton()
  2489. */
  2490. public function clickWithLeftButton($cssOrXPath = null, $offsetX = null, $offsetY = null) {
  2491. return $this->getScenario()->runStep(new \Codeception\Step\Action('clickWithLeftButton', func_get_args()));
  2492. }
  2493. /**
  2494. * [!] Method is generated. Documentation taken from corresponding module.
  2495. *
  2496. * Performs contextual click with the right mouse button on an element.
  2497. * If the first parameter `null` then the offset is relative to the actual mouse position.
  2498. * If the second and third parameters are given,
  2499. * then the mouse is moved to an offset of the element's top-left corner.
  2500. * Otherwise, the mouse is moved to the center of the element.
  2501. *
  2502. * ``` php
  2503. * <?php
  2504. * $I->clickWithRightButton(['css' => '.checkout']);
  2505. * $I->clickWithRightButton(null, 20, 50);
  2506. * $I->clickWithRightButton(['css' => '.checkout'], 20, 50);
  2507. * ?>
  2508. * ```
  2509. *
  2510. * @param string $cssOrXPath css or xpath of the web element (body by default).
  2511. * @param int $offsetX
  2512. * @param int $offsetY
  2513. *
  2514. * @throws \Codeception\Exception\ElementNotFound
  2515. * @see \Codeception\Module\WebDriver::clickWithRightButton()
  2516. */
  2517. public function clickWithRightButton($cssOrXPath = null, $offsetX = null, $offsetY = null) {
  2518. return $this->getScenario()->runStep(new \Codeception\Step\Action('clickWithRightButton', func_get_args()));
  2519. }
  2520. /**
  2521. * [!] Method is generated. Documentation taken from corresponding module.
  2522. *
  2523. * Pauses test execution in debug mode.
  2524. * To proceed test press "ENTER" in console.
  2525. *
  2526. * This method is useful while writing tests,
  2527. * since it allows you to inspect the current page in the middle of a test case.
  2528. * @see \Codeception\Module\WebDriver::pauseExecution()
  2529. */
  2530. public function pauseExecution() {
  2531. return $this->getScenario()->runStep(new \Codeception\Step\Action('pauseExecution', func_get_args()));
  2532. }
  2533. /**
  2534. * [!] Method is generated. Documentation taken from corresponding module.
  2535. *
  2536. * Performs a double-click on an element matched by CSS or XPath.
  2537. *
  2538. * @param $cssOrXPath
  2539. * @throws \Codeception\Exception\ElementNotFound
  2540. * @see \Codeception\Module\WebDriver::doubleClick()
  2541. */
  2542. public function doubleClick($cssOrXPath) {
  2543. return $this->getScenario()->runStep(new \Codeception\Step\Action('doubleClick', func_get_args()));
  2544. }
  2545. /**
  2546. * [!] Method is generated. Documentation taken from corresponding module.
  2547. *
  2548. * Presses the given key on the given element.
  2549. * To specify a character and modifier (e.g. ctrl, alt, shift, meta), pass an array for $char with
  2550. * the modifier as the first element and the character as the second.
  2551. * For special keys use key constants from WebDriverKeys class.
  2552. *
  2553. * ``` php
  2554. * <?php
  2555. * // <input id="page" value="old" />
  2556. * $I->pressKey('#page','a'); // => olda
  2557. * $I->pressKey('#page',array('ctrl','a'),'new'); //=> new
  2558. * $I->pressKey('#page',array('shift','111'),'1','x'); //=> old!!!1x
  2559. * $I->pressKey('descendant-or-self::*[@id='page']','u'); //=> oldu
  2560. * $I->pressKey('#name', array('ctrl', 'a'), \Facebook\WebDriver\WebDriverKeys::DELETE); //=>''
  2561. * ?>
  2562. * ```
  2563. *
  2564. * @param $element
  2565. * @param $char string|array Can be char or array with modifier. You can provide several chars.
  2566. * @throws \Codeception\Exception\ElementNotFound
  2567. * @see \Codeception\Module\WebDriver::pressKey()
  2568. */
  2569. public function pressKey($element, $char) {
  2570. return $this->getScenario()->runStep(new \Codeception\Step\Action('pressKey', func_get_args()));
  2571. }
  2572. /**
  2573. * [!] Method is generated. Documentation taken from corresponding module.
  2574. *
  2575. * Append the given text to the given element.
  2576. * Can also add a selection to a select box.
  2577. *
  2578. * ``` php
  2579. * <?php
  2580. * $I->appendField('#mySelectbox', 'SelectValue');
  2581. * $I->appendField('#myTextField', 'appended');
  2582. * ?>
  2583. * ```
  2584. *
  2585. * @param string $field
  2586. * @param string $value
  2587. * @throws \Codeception\Exception\ElementNotFound
  2588. * @see \Codeception\Module\WebDriver::appendField()
  2589. */
  2590. public function appendField($field, $value) {
  2591. return $this->getScenario()->runStep(new \Codeception\Step\Action('appendField', func_get_args()));
  2592. }
  2593. /**
  2594. * [!] Method is generated. Documentation taken from corresponding module.
  2595. *
  2596. * @param string $name
  2597. * @see \Codeception\Module\WebDriver::saveSessionSnapshot()
  2598. */
  2599. public function saveSessionSnapshot($name) {
  2600. return $this->getScenario()->runStep(new \Codeception\Step\Action('saveSessionSnapshot', func_get_args()));
  2601. }
  2602. /**
  2603. * [!] Method is generated. Documentation taken from corresponding module.
  2604. *
  2605. * @param string $name
  2606. * @return bool
  2607. * @see \Codeception\Module\WebDriver::loadSessionSnapshot()
  2608. */
  2609. public function loadSessionSnapshot($name) {
  2610. return $this->getScenario()->runStep(new \Codeception\Step\Action('loadSessionSnapshot', func_get_args()));
  2611. }
  2612. /**
  2613. * [!] Method is generated. Documentation taken from corresponding module.
  2614. *
  2615. * Move to the middle of the given element matched by the given locator.
  2616. * Extra shift, calculated from the top-left corner of the element,
  2617. * can be set by passing $offsetX and $offsetY parameters.
  2618. *
  2619. * ``` php
  2620. * <?php
  2621. * $I->scrollTo(['css' => '.checkout'], 20, 50);
  2622. * ?>
  2623. * ```
  2624. *
  2625. * @param $selector
  2626. * @param int $offsetX
  2627. * @param int $offsetY
  2628. * @see \Codeception\Module\WebDriver::scrollTo()
  2629. */
  2630. public function scrollTo($selector, $offsetX = null, $offsetY = null) {
  2631. return $this->getScenario()->runStep(new \Codeception\Step\Action('scrollTo', func_get_args()));
  2632. }
  2633. /**
  2634. * [!] Method is generated. Documentation taken from corresponding module.
  2635. *
  2636. * Opens a new browser tab (wherever it is possible) and switches to it.
  2637. *
  2638. * ```php
  2639. * <?php
  2640. * $I->openNewTab();
  2641. * ```
  2642. * Tab is opened by using `window.open` javascript in a browser.
  2643. * Please note, that adblock can restrict creating such tabs.
  2644. *
  2645. * Can't be used with PhantomJS
  2646. *
  2647. * @see \Codeception\Module\WebDriver::openNewTab()
  2648. */
  2649. public function openNewTab() {
  2650. return $this->getScenario()->runStep(new \Codeception\Step\Action('openNewTab', func_get_args()));
  2651. }
  2652. /**
  2653. * [!] Method is generated. Documentation taken from corresponding module.
  2654. *
  2655. * Closes current browser tab and switches to previous active tab.
  2656. *
  2657. * ```php
  2658. * <?php
  2659. * $I->closeTab();
  2660. * ```
  2661. *
  2662. * Can't be used with PhantomJS
  2663. * @see \Codeception\Module\WebDriver::closeTab()
  2664. */
  2665. public function closeTab() {
  2666. return $this->getScenario()->runStep(new \Codeception\Step\Action('closeTab', func_get_args()));
  2667. }
  2668. /**
  2669. * [!] Method is generated. Documentation taken from corresponding module.
  2670. *
  2671. * Switches to next browser tab.
  2672. * An offset can be specified.
  2673. *
  2674. * ```php
  2675. * <?php
  2676. * // switch to next tab
  2677. * $I->switchToNextTab();
  2678. * // switch to 2nd next tab
  2679. * $I->switchToNextTab(2);
  2680. * ```
  2681. *
  2682. * Can't be used with PhantomJS
  2683. *
  2684. * @param int $offset 1
  2685. * @see \Codeception\Module\WebDriver::switchToNextTab()
  2686. */
  2687. public function switchToNextTab($offset = null) {
  2688. return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToNextTab', func_get_args()));
  2689. }
  2690. /**
  2691. * [!] Method is generated. Documentation taken from corresponding module.
  2692. *
  2693. * Switches to previous browser tab.
  2694. * An offset can be specified.
  2695. *
  2696. * ```php
  2697. * <?php
  2698. * // switch to previous tab
  2699. * $I->switchToPreviousTab();
  2700. * // switch to 2nd previous tab
  2701. * $I->switchToPreviousTab(2);
  2702. * ```
  2703. *
  2704. * Can't be used with PhantomJS
  2705. *
  2706. * @param int $offset 1
  2707. * @see \Codeception\Module\WebDriver::switchToPreviousTab()
  2708. */
  2709. public function switchToPreviousTab($offset = null) {
  2710. return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToPreviousTab', func_get_args()));
  2711. }
  2712. /**
  2713. * [!] Method is generated. Documentation taken from corresponding module.
  2714. *
  2715. * Waits for element and runs a sequence of actions inside its context.
  2716. * Actions can be defined with array, callback, or `Codeception\Util\ActionSequence` instance.
  2717. *
  2718. * Actions as array are recommended for simple to combine "waitForElement" with assertions;
  2719. * `waitForElement($el)` and `see('text', $el)` can be simplified to:
  2720. *
  2721. * ```php
  2722. * <?php
  2723. * $I->performOn($el, ['see' => 'text']);
  2724. * ```
  2725. *
  2726. * List of actions can be pragmatically build using `Codeception\Util\ActionSequence`:
  2727. *
  2728. * ```php
  2729. * <?php
  2730. * $I->performOn('.model', ActionSequence::build()
  2731. * ->see('Warning')
  2732. * ->see('Are you sure you want to delete this?')
  2733. * ->click('Yes')
  2734. * );
  2735. * ```
  2736. *
  2737. * Actions executed from array or ActionSequence will print debug output for actions, and adds an action name to
  2738. * exception on failure.
  2739. *
  2740. * Whenever you need to define more actions a callback can be used. A WebDriver module is passed for argument:
  2741. *
  2742. * ```php
  2743. * <?php
  2744. * $I->performOn('.rememberMe', function (WebDriver $I) {
  2745. * $I->see('Remember me next time');
  2746. * $I->seeElement('#LoginForm_rememberMe');
  2747. * $I->dontSee('Login');
  2748. * });
  2749. * ```
  2750. *
  2751. * In 3rd argument you can set number a seconds to wait for element to appear
  2752. *
  2753. * @param $element
  2754. * @param $actions
  2755. * @param int $timeout
  2756. * @see \Codeception\Module\WebDriver::performOn()
  2757. */
  2758. public function performOn($element, $actions, $timeout = null) {
  2759. return $this->getScenario()->runStep(new \Codeception\Step\Action('performOn', func_get_args()));
  2760. }
  2761. /**
  2762. * [!] Method is generated. Documentation taken from corresponding module.
  2763. *
  2764. * Compare the reference image with a current screenshot, identified by their indentifier name
  2765. * and their element ID.
  2766. *
  2767. * @param string $identifier Identifies your test object
  2768. * @param string $elementID DOM ID of the element, which should be screenshotted
  2769. * @param string|array $excludeElements Element name or array of Element names, which should not appear in the screenshot
  2770. * @param float $deviation
  2771. * Conditional Assertion: Test won't be stopped on fail
  2772. * @see \Codeception\Module\VisualCeption::seeVisualChanges()
  2773. */
  2774. public function canSeeVisualChanges($identifier, $elementID = null, $excludeElements = null, $deviation = null) {
  2775. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeVisualChanges', func_get_args()));
  2776. }
  2777. /**
  2778. * [!] Method is generated. Documentation taken from corresponding module.
  2779. *
  2780. * Compare the reference image with a current screenshot, identified by their indentifier name
  2781. * and their element ID.
  2782. *
  2783. * @param string $identifier Identifies your test object
  2784. * @param string $elementID DOM ID of the element, which should be screenshotted
  2785. * @param string|array $excludeElements Element name or array of Element names, which should not appear in the screenshot
  2786. * @param float $deviation
  2787. * @see \Codeception\Module\VisualCeption::seeVisualChanges()
  2788. */
  2789. public function seeVisualChanges($identifier, $elementID = null, $excludeElements = null, $deviation = null) {
  2790. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeVisualChanges', func_get_args()));
  2791. }
  2792. /**
  2793. * [!] Method is generated. Documentation taken from corresponding module.
  2794. *
  2795. * Compare the reference image with a current screenshot, identified by their indentifier name
  2796. * and their element ID.
  2797. *
  2798. * @param string $identifier identifies your test object
  2799. * @param string $elementID DOM ID of the element, which should be screenshotted
  2800. * @param string|array $excludeElements string of Element name or array of Element names, which should not appear in the screenshot
  2801. * @param float $deviation
  2802. * Conditional Assertion: Test won't be stopped on fail
  2803. * @see \Codeception\Module\VisualCeption::dontSeeVisualChanges()
  2804. */
  2805. public function cantSeeVisualChanges($identifier, $elementID = null, $excludeElements = null, $deviation = null) {
  2806. return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeVisualChanges', func_get_args()));
  2807. }
  2808. /**
  2809. * [!] Method is generated. Documentation taken from corresponding module.
  2810. *
  2811. * Compare the reference image with a current screenshot, identified by their indentifier name
  2812. * and their element ID.
  2813. *
  2814. * @param string $identifier identifies your test object
  2815. * @param string $elementID DOM ID of the element, which should be screenshotted
  2816. * @param string|array $excludeElements string of Element name or array of Element names, which should not appear in the screenshot
  2817. * @param float $deviation
  2818. * @see \Codeception\Module\VisualCeption::dontSeeVisualChanges()
  2819. */
  2820. public function dontSeeVisualChanges($identifier, $elementID = null, $excludeElements = null, $deviation = null) {
  2821. return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeVisualChanges', func_get_args()));
  2822. }
  2823. }