steps.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. type ICodeceptCallback = (i: CodeceptJS.I) => void;
  2. declare class FeatureConfig {
  3. retry(times:number): FeatureConfig
  4. timeout(seconds:number): FeatureConfig
  5. config(config:object): FeatureConfig
  6. config(helperName:string, config:object): FeatureConfig
  7. }
  8. declare class ScenarioConfig {
  9. throws(err:any) : ScenarioConfig;
  10. fails() : ScenarioConfig;
  11. retry(times:number): ScenarioConfig
  12. timeout(timeout:number): ScenarioConfig
  13. inject(inject:object): ScenarioConfig
  14. config(config:object): ScenarioConfig
  15. config(helperName:string, config:object): ScenarioConfig
  16. }
  17. interface ILocator {
  18. xpath?: string;
  19. css?: string;
  20. name?: string;
  21. value?: string;
  22. frame?: string;
  23. android?: string;
  24. ios?: string;
  25. }
  26. declare class Helper {
  27. /** Abstract method to provide required config options */
  28. static _config(): any;
  29. /** Abstract method to validate config */
  30. _validateConfig<T>(config: T): T;
  31. /** Sets config for current test */
  32. _setConfig(opts: any): void;
  33. /** Hook executed before all tests */
  34. _init(): void
  35. /** Hook executed before each test. */
  36. _before(): void
  37. /** Hook executed after each test */
  38. _after(): void
  39. /**
  40. * Hook provides a test details
  41. * Executed in the very beginning of a test
  42. */
  43. _test(test): void
  44. /** Hook executed after each passed test */
  45. _passed(test: () => void): void
  46. /** Hook executed after each failed test */
  47. _failed(test: () => void): void
  48. /** Hook executed before each step */
  49. _beforeStep(step: () => void): void
  50. /** Hook executed after each step */
  51. _afterStep(step: () => void): void
  52. /** Hook executed before each suite */
  53. _beforeSuite(suite: () => void): void
  54. /** Hook executed after each suite */
  55. _afterSuite(suite: () => void): void
  56. /** Hook executed after all tests are executed */
  57. _finishTest(suite: () => void): void
  58. /**Access another configured helper: this.helpers['AnotherHelper'] */
  59. get helpers(): any
  60. /** Print debug message to console (outputs only in debug mode) */
  61. debug(msg: string): void
  62. debugSection(section: string, msg: string): void
  63. }
  64. declare class Locator implements ILocator {
  65. xpath?: string;
  66. css?: string;
  67. name?: string;
  68. value?: string;
  69. frame?: string;
  70. android?: string;
  71. ios?: string;
  72. or(locator:string): Locator;
  73. find(locator:string): Locator;
  74. withChild(locator:string): Locator;
  75. find(locator:string): Locator;
  76. at(position:number): Locator;
  77. first(): Locator;
  78. last(): Locator;
  79. inside(locator:string): Locator;
  80. before(locator:string): Locator;
  81. after(locator:string): Locator;
  82. withText(locator:string): Locator;
  83. withAttr(locator:object): Locator;
  84. as(locator:string): Locator;
  85. }
  86. declare function actor(customSteps?: {}): CodeceptJS.I;
  87. declare function Feature(title: string, opts?: {}): FeatureConfig;
  88. declare const Scenario: {
  89. (title: string, callback: ICodeceptCallback): ScenarioConfig;
  90. (title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig;
  91. only(title: string, callback: ICodeceptCallback): ScenarioConfig;
  92. only(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig;
  93. }
  94. declare function xScenario(title: string, callback: ICodeceptCallback): ScenarioConfig;
  95. declare function xScenario(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig;
  96. declare function Data(data: any): any;
  97. declare function xData(data: any): any;
  98. declare function Before(callback: ICodeceptCallback): void;
  99. declare function BeforeSuite(callback: ICodeceptCallback): void;
  100. declare function After(callback: ICodeceptCallback): void;
  101. declare function AfterSuite(callback: ICodeceptCallback): void;
  102. declare function locate(selector: string): Locator;
  103. declare function locate(selector: ILocator): Locator;
  104. declare function within(selector: string, callback: Function): Promise<any>;
  105. declare function within(selector: ILocator, callback: Function): Promise<any>;
  106. declare function session(selector: string, callback: Function): Promise<any>;
  107. declare function session(selector: ILocator, callback: Function): Promise<any>;
  108. declare function session(selector: string, config: any, callback: Function): Promise<any>;
  109. declare function session(selector: ILocator, config: any, callback: Function): Promise<any>;
  110. declare function pause(): void;
  111. declare const codeceptjs: any;
  112. declare namespace CodeceptJS {
  113. export interface I {
  114. defineTimeout(timeouts: string) : void,
  115. amOnPage(url: string) : void,
  116. click(locator: ILocator, context?: ILocator) : void,
  117. click(locator: string, context?: ILocator) : void,
  118. click(locator: ILocator, context?: string) : void,
  119. click(locator: string, context?: string) : void,
  120. doubleClick(locator: ILocator, context?: ILocator) : void,
  121. doubleClick(locator: string, context?: ILocator) : void,
  122. doubleClick(locator: ILocator, context?: string) : void,
  123. doubleClick(locator: string, context?: string) : void,
  124. rightClick(locator: ILocator) : void,
  125. rightClick(locator: string) : void,
  126. fillField(field: ILocator, value: string) : void,
  127. fillField(field: string, value: string) : void,
  128. appendField(field: ILocator, value: string) : void,
  129. appendField(field: string, value: string) : void,
  130. clearField(field: ILocator) : void,
  131. clearField(field: string) : void,
  132. selectOption(select: ILocator, option: string) : void,
  133. selectOption(select: string, option: string) : void,
  134. attachFile(locator: ILocator, pathToFile: string) : void,
  135. attachFile(locator: string, pathToFile: string) : void,
  136. checkOption(field: ILocator, context?: ILocator) : void,
  137. checkOption(field: string, context?: ILocator) : void,
  138. checkOption(field: ILocator, context?: string) : void,
  139. checkOption(field: string, context?: string) : void,
  140. uncheckOption(field: ILocator, context?: ILocator) : void,
  141. uncheckOption(field: string, context?: ILocator) : void,
  142. uncheckOption(field: ILocator, context?: string) : void,
  143. uncheckOption(field: string, context?: string) : void,
  144. grabTextFrom(locator: ILocator) : Promise<string>,
  145. grabTextFrom(locator: string) : Promise<string>,
  146. grabHTMLFrom(locator: ILocator) : Promise<string>,
  147. grabHTMLFrom(locator: string) : Promise<string>,
  148. grabValueFrom(locator: ILocator) : Promise<string>,
  149. grabValueFrom(locator: string) : Promise<string>,
  150. grabCssPropertyFrom(locator: ILocator, cssProperty: string) : Promise<string>,
  151. grabCssPropertyFrom(locator: string, cssProperty: string) : Promise<string>,
  152. grabAttributeFrom(locator: ILocator, attr: string) : Promise<string>,
  153. grabAttributeFrom(locator: string, attr: string) : Promise<string>,
  154. seeInTitle(text: string) : void,
  155. seeTitleEquals(text: string) : void,
  156. dontSeeInTitle(text: string) : void,
  157. grabTitle() : Promise<string>,
  158. see(text: string, context?: ILocator) : void,
  159. see(text: string, context?: string) : void,
  160. seeTextEquals(text: string, context?: ILocator) : void,
  161. seeTextEquals(text: string, context?: string) : void,
  162. dontSee(text: string, context?: ILocator) : void,
  163. dontSee(text: string, context?: string) : void,
  164. seeInField(field: ILocator, value: string) : void,
  165. seeInField(field: string, value: string) : void,
  166. dontSeeInField(field: ILocator, value: string) : void,
  167. dontSeeInField(field: string, value: string) : void,
  168. seeCheckboxIsChecked(field: ILocator) : void,
  169. seeCheckboxIsChecked(field: string) : void,
  170. dontSeeCheckboxIsChecked(field: ILocator) : void,
  171. dontSeeCheckboxIsChecked(field: string) : void,
  172. seeElement(locator: ILocator) : void,
  173. seeElement(locator: string) : void,
  174. dontSeeElement(locator: ILocator) : void,
  175. dontSeeElement(locator: string) : void,
  176. seeElementInDOM(locator: ILocator) : void,
  177. seeElementInDOM(locator: string) : void,
  178. dontSeeElementInDOM(locator: ILocator) : void,
  179. dontSeeElementInDOM(locator: string) : void,
  180. seeInSource(text: string) : void,
  181. grabSource() : Promise<string>,
  182. grabBrowserLogs() : Promise<string>,
  183. grabCurrentUrl() : Promise<string>,
  184. grabBrowserUrl() : Promise<string>,
  185. dontSeeInSource(text: string) : void,
  186. seeNumberOfElements(selector: string, num: number) : void,
  187. seeNumberOfVisibleElements(locator: ILocator, num: number) : void,
  188. seeNumberOfVisibleElements(locator: string, num: number) : void,
  189. seeCssPropertiesOnElements(locator: ILocator, cssProperties: string) : void,
  190. seeCssPropertiesOnElements(locator: string, cssProperties: string) : void,
  191. seeAttributesOnElements(locator: ILocator, attributes: string) : void,
  192. seeAttributesOnElements(locator: string, attributes: string) : void,
  193. grabNumberOfVisibleElements(locator: ILocator) : Promise<string>,
  194. grabNumberOfVisibleElements(locator: string) : Promise<string>,
  195. seeInCurrentUrl(url: string) : void,
  196. dontSeeInCurrentUrl(url: string) : void,
  197. seeCurrentUrlEquals(url: string) : void,
  198. dontSeeCurrentUrlEquals(url: string) : void,
  199. executeScript(fn: Function) : void,
  200. executeAsyncScript(fn: Function) : void,
  201. scrollTo(locator: ILocator, offsetX?: number, offsetY?: number) : void,
  202. scrollTo(locator: string, offsetX?: number, offsetY?: number) : void,
  203. moveCursorTo(locator: ILocator, offsetX?: number, offsetY?: number) : void,
  204. moveCursorTo(locator: string, offsetX?: number, offsetY?: number) : void,
  205. saveScreenshot(fileName: string, fullPage?: string) : void,
  206. setCookie(cookie: string) : void,
  207. clearCookie(cookie: string) : void,
  208. seeCookie(name: string) : void,
  209. dontSeeCookie(name: string) : void,
  210. grabCookie(name: string) : Promise<string>,
  211. acceptPopup() : void,
  212. cancelPopup() : void,
  213. seeInPopup(text: string) : void,
  214. grabPopupText() : Promise<string>,
  215. pressKey(key: string) : void,
  216. resizeWindow(width: number, height: number) : void,
  217. dragAndDrop(srcElement: string, destElement: string) : void,
  218. closeOtherTabs() : void,
  219. wait(sec: number) : void,
  220. waitForEnabled(locator: ILocator, sec?: number) : void,
  221. waitForEnabled(locator: string, sec?: number) : void,
  222. waitForElement(locator: ILocator, sec?: number) : void,
  223. waitForElement(locator: string, sec?: number) : void,
  224. waitUntilExists(locator: ILocator, sec?: number) : void,
  225. waitUntilExists(locator: string, sec?: number) : void,
  226. waitInUrl(urlPart: string, sec?: number) : void,
  227. waitUrlEquals(urlPart: string, sec?: number) : void,
  228. waitForText(text: string, sec?: number, aContext?: string) : void,
  229. waitForValue(field: ILocator, value: string, sec?: number) : void,
  230. waitForValue(field: string, value: string, sec?: number) : void,
  231. waitForVisible(locator: ILocator, sec?: number) : void,
  232. waitForVisible(locator: string, sec?: number) : void,
  233. waitNumberOfVisibleElements(locator: ILocator, num: number, sec?: number) : void,
  234. waitNumberOfVisibleElements(locator: string, num: number, sec?: number) : void,
  235. waitForInvisible(locator: ILocator, sec?: number) : void,
  236. waitForInvisible(locator: string, sec?: number) : void,
  237. waitToHide(locator: ILocator, sec?: number) : void,
  238. waitToHide(locator: string, sec?: number) : void,
  239. waitForStalenessOf(locator: ILocator, sec?: number) : void,
  240. waitForStalenessOf(locator: string, sec?: number) : void,
  241. waitForDetached(locator: ILocator, sec?: number) : void,
  242. waitForDetached(locator: string, sec?: number) : void,
  243. waitForFunction(fn: Function, argsOrSec?: string, sec?: number) : void,
  244. waitUntil(fn: Function, sec?: number, timeoutMsg?: string) : void,
  245. switchTo(locator: ILocator) : void,
  246. switchTo(locator: string) : void,
  247. switchToNextTab(num?: number, sec?: number) : void,
  248. switchToPreviousTab(num?: number, sec?: number) : void,
  249. closeCurrentTab() : void,
  250. openNewTab() : void,
  251. grabNumberOfOpenTabs() : Promise<string>,
  252. refreshPage() : void,
  253. scrollPageToTop() : void,
  254. scrollPageToBottom() : void,
  255. grabPageScrollPosition() : Promise<string>,
  256. runOnIOS(caps: string, fn: Function) : void,
  257. runOnAndroid(caps: string, fn: Function) : void,
  258. runInWeb(fn: Function) : void,
  259. debug(msg: string) : void,
  260. debugSection(section: string, msg: string) : void,
  261. say(msg: string) : void,
  262. retryStep(opts: string) : void,
  263. }
  264. }
  265. declare module "codeceptjs" {
  266. export = CodeceptJS;
  267. }