configurationManagement.spec.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. const fs = require('fs');
  2. const path = require('path');
  3. const chai = require('chai');
  4. const should = chai.should();
  5. const JWebDriver = require('jwebdriver');
  6. chai.use(JWebDriver.chaiSupportChainPromise);
  7. const resemble = require('resemblejs-node');
  8. resemble.outputSettings({
  9. errorType: 'flatDifferenceIntensity',
  10. });
  11. const rootPath = getRootPath();
  12. module.exports = function() {
  13. let driver, testVars;
  14. before(function() {
  15. let self = this;
  16. driver = self.driver;
  17. testVars = self.testVars;
  18. });
  19. it('url: http://127.0.0.1:8811', async function() {
  20. await driver.url(_(`http://127.0.0.1:8811`));
  21. });
  22. it('waitBody: ', async function() {
  23. await driver
  24. .sleep(500)
  25. .wait('body', 30000)
  26. .html()
  27. .then(function(code) {
  28. isPageError(code).should.be.false;
  29. });
  30. });
  31. it('click: #username, 89, 41, 0', async function() {
  32. await driver
  33. .sleep(300)
  34. .wait('#username', 30000)
  35. .sleep(300)
  36. .mouseMove(89, 41)
  37. .click(0);
  38. });
  39. it('sendKeys: seata', async function() {
  40. await driver.sendKeys('seata');
  41. });
  42. it('click: #password, 53, 34, 0', async function() {
  43. await driver
  44. .sleep(300)
  45. .wait('#password', 30000)
  46. .sleep(300)
  47. .mouseMove(53, 34)
  48. .click(0);
  49. });
  50. it('sendKeys: seata', async function() {
  51. await driver.sendKeys('seata');
  52. });
  53. it('click: 提交 ( //button[text()="提交"], 321, 30, 0 )', async function() {
  54. await driver
  55. .sleep(300)
  56. .wait('//button[text()="提交"]', 30000)
  57. .sleep(300)
  58. .mouseMove(321, 30)
  59. .click(0);
  60. });
  61. it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 178, 9, 0', async function() {
  62. await driver
  63. .sleep(300)
  64. .wait(
  65. 'div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]',
  66. 30000
  67. )
  68. .sleep(300)
  69. .mouseMove(178, 9)
  70. .click(0);
  71. });
  72. it('sendKeys: test_test', async function() {
  73. await driver.sendKeys('test_test');
  74. });
  75. it('click: 查询 ( //button[text()="查询"], 3, 9, 0 )', async function() {
  76. await driver
  77. .sleep(300)
  78. .wait('//button[text()="查询"]', 30000)
  79. .sleep(300)
  80. .mouseMove(3, 9)
  81. .click(0);
  82. });
  83. it('click: #viewFramework-product-body i.next-icon-add, 15, 27, 0', async function() {
  84. await driver
  85. .sleep(300)
  86. .wait('#viewFramework-product-body i.next-icon-add', 30000)
  87. .sleep(300)
  88. .mouseMove(15, 27)
  89. .click(0);
  90. });
  91. it('click: Data ID: ( #dataId, 154, 20, 0 )', async function() {
  92. await driver
  93. .sleep(300)
  94. .wait('#dataId', 30000)
  95. .sleep(300)
  96. .mouseMove(154, 20)
  97. .click(0);
  98. });
  99. it('sendKeys: test_test', async function() {
  100. await driver.sendKeys('test_test');
  101. });
  102. it('dblClick: Group: ( #group, 89, 11, 0 )', async function() {
  103. await driver
  104. .sleep(300)
  105. .wait('#group', 30000)
  106. .sleep(300)
  107. .mouseMove(89, 11)
  108. .click(0)
  109. .click(0);
  110. });
  111. it('click: #viewFramework-product-body i.next-icon-delete-filling, 11, 7, 0', async function() {
  112. await driver
  113. .sleep(300)
  114. .wait('#viewFramework-product-body i.next-icon-delete-filling', 30000)
  115. .sleep(300)
  116. .mouseMove(11, 7)
  117. .click(0);
  118. });
  119. it('sendKeys: test', async function() {
  120. await driver.sendKeys('test');
  121. });
  122. it('click: 更多高级选项 ( //a[text()="更多高级选项"], 61, 3, 0 )', async function() {
  123. await driver
  124. .sleep(300)
  125. .wait('//a[text()="更多高级选项"]', 30000)
  126. .sleep(300)
  127. .mouseMove(61, 3)
  128. .click(0);
  129. });
  130. it('click: span.next-select-trigger-search > input[role="combobox"]:nth-child(1), 66, 8, 0', async function() {
  131. await driver
  132. .sleep(300)
  133. .wait('span.next-select-trigger-search > input[role="combobox"]:nth-child(1)', 30000)
  134. .sleep(300)
  135. .mouseMove(66, 8)
  136. .click(0);
  137. });
  138. it('click: span.next-select-trigger-search > input[role="combobox"]:nth-child(1), 71, 16, 0', async function() {
  139. await driver
  140. .sleep(300)
  141. .wait('span.next-select-trigger-search > input[role="combobox"]:nth-child(1)', 30000)
  142. .sleep(300)
  143. .mouseMove(71, 16)
  144. .click(0);
  145. });
  146. it('click: 归属应用: ( #appName, 50, 19, 0 )', async function() {
  147. await driver
  148. .sleep(300)
  149. .wait('#appName', 30000)
  150. .sleep(300)
  151. .mouseMove(50, 19)
  152. .click(0);
  153. });
  154. it('click: 收起 ( //a[text()="收起"], 16, 5, 0 )', async function() {
  155. await driver
  156. .sleep(300)
  157. .wait('//a[text()="收起"]', 30000)
  158. .sleep(300)
  159. .mouseMove(16, 5)
  160. .click(0);
  161. });
  162. it('click: #desc, 77, 40, 0', async function() {
  163. await driver
  164. .sleep(300)
  165. .wait('#desc', 30000)
  166. .sleep(300)
  167. .mouseMove(77, 40)
  168. .click(0);
  169. });
  170. it('sendKeys: test', async function() {
  171. await driver.sendKeys('test');
  172. });
  173. it('scrollElementTo: #viewFramework-product-body, 0, 49', async function() {
  174. await driver
  175. .sleep(300)
  176. .wait('#viewFramework-product-body', 30000)
  177. .sleep(300)
  178. .scrollElementTo(0, 49);
  179. });
  180. it('click: #container div.view-line, 60, 15, 0', async function() {
  181. await driver
  182. .sleep(300)
  183. .wait('#container div.view-line', 30000)
  184. .sleep(300)
  185. .mouseMove(60, 15)
  186. .click(0);
  187. });
  188. it('sendKeys: test', async function() {
  189. await driver.sendKeys('test');
  190. });
  191. it('scrollElementTo: #viewFramework-product-body, 0, 155', async function() {
  192. await driver
  193. .sleep(300)
  194. .wait('#viewFramework-product-body', 30000)
  195. .sleep(300)
  196. .scrollElementTo(0, 155);
  197. });
  198. it('click: 发布 ( //button[text()="发布"], 39, 9, 0 )', async function() {
  199. await driver
  200. .sleep(300)
  201. .wait('//button[text()="发布"]', 30000)
  202. .sleep(300)
  203. .mouseMove(39, 9)
  204. .click(0);
  205. });
  206. it('× click: 确定 ( //button[text()="确定"], 13, 9, 0 )', async function() {
  207. await driver
  208. .sleep(300)
  209. .wait('//button[text()="确定"]', 30000)
  210. .sleep(300)
  211. .mouseMove(13, 9)
  212. .click(0);
  213. });
  214. it('click: 返回 ( //button[text()="返回"], 39, 18, 0 )', async function() {
  215. await driver
  216. .sleep(300)
  217. .wait('//button[text()="返回"]', 30000)
  218. .sleep(300)
  219. .mouseMove(39, 18)
  220. .click(0);
  221. });
  222. it('scrollElementTo: #viewFramework-product-body, 0, 0', async function() {
  223. await driver
  224. .sleep(300)
  225. .wait('#viewFramework-product-body', 30000)
  226. .sleep(300)
  227. .scrollElementTo(0, 0);
  228. });
  229. it('click: 详情 ( //a[text()="详情"], 12, 7, 0 )', async function() {
  230. await driver
  231. .sleep(300)
  232. .wait('//a[text()="详情"]', 30000)
  233. .sleep(300)
  234. .mouseMove(12, 7)
  235. .click(0);
  236. });
  237. it('scrollElementTo: #viewFramework-product-body, 0, 22', async function() {
  238. await driver
  239. .sleep(300)
  240. .wait('#viewFramework-product-body', 30000)
  241. .sleep(300)
  242. .scrollElementTo(0, 22);
  243. });
  244. it('click: test ( #content, 225, 35, 0 )', async function() {
  245. await driver
  246. .sleep(300)
  247. .wait('#content', 30000)
  248. .sleep(300)
  249. .mouseMove(225, 35)
  250. .click(0);
  251. });
  252. it('click: #backarrow, 13, 10, 0', async function() {
  253. await driver
  254. .sleep(300)
  255. .wait('#backarrow', 30000)
  256. .sleep(300)
  257. .mouseMove(13, 10)
  258. .click(0);
  259. });
  260. it('scrollElementTo: #viewFramework-product-body, 0, 0', async function() {
  261. await driver
  262. .sleep(300)
  263. .wait('#viewFramework-product-body', 30000)
  264. .sleep(300)
  265. .scrollElementTo(0, 0);
  266. });
  267. it('click: 示例代码 ( //a[text()="示例代码"], 29, 6, 0 )', async function() {
  268. await driver
  269. .sleep(300)
  270. .wait('//a[text()="示例代码"]', 30000)
  271. .sleep(300)
  272. .mouseMove(29, 6)
  273. .click(0);
  274. });
  275. it('click: Spring Boot ( li[role="tab"]:nth-child(2) > div.next-tabs-tab-inner, 63, 22, 0 )', async function() {
  276. await driver
  277. .sleep(300)
  278. .wait('li[role="tab"]:nth-child(2) > div.next-tabs-tab-inner', 30000)
  279. .sleep(300)
  280. .mouseMove(63, 22)
  281. .click(0);
  282. });
  283. it('click: i.next-icon-close, 9, 10, 0', async function() {
  284. await driver
  285. .sleep(300)
  286. .wait('i.next-icon-close', 30000)
  287. .sleep(300)
  288. .mouseMove(9, 10)
  289. .click(0);
  290. });
  291. it('click: 编辑 ( //a[text()="编辑"], 14, 6, 0 )', async function() {
  292. await driver
  293. .sleep(300)
  294. .wait('//a[text()="编辑"]', 30000)
  295. .sleep(300)
  296. .mouseMove(14, 6)
  297. .click(0);
  298. });
  299. it('scrollElementTo: #viewFramework-product-body, 0, 134', async function() {
  300. await driver
  301. .sleep(300)
  302. .wait('#viewFramework-product-body', 30000)
  303. .sleep(300)
  304. .scrollElementTo(0, 134);
  305. });
  306. it('click: label:nth-child(2) > span.next-radio > input[type="radio"][role="radio"].next-radio-input, 7, 1, 0', async function() {
  307. await driver
  308. .sleep(300)
  309. .wait(
  310. 'label:nth-child(2) > span.next-radio > input[type="radio"][role="radio"].next-radio-input',
  311. 30000
  312. )
  313. .sleep(300)
  314. .mouseMove(7, 1)
  315. .click(0);
  316. });
  317. it('click: label:nth-child(1) > span.next-radio > input[type="radio"][role="radio"].next-radio-input, 8, 8, 0', async function() {
  318. await driver
  319. .sleep(300)
  320. .wait(
  321. 'label:nth-child(1) > span.next-radio > input[type="radio"][role="radio"].next-radio-input',
  322. 30000
  323. )
  324. .sleep(300)
  325. .mouseMove(8, 8)
  326. .click(0);
  327. });
  328. it('click: test ( #container div.view-line, 47, 11, 0 )', async function() {
  329. await driver
  330. .sleep(300)
  331. .wait('#container div.view-line', 30000)
  332. .sleep(300)
  333. .mouseMove(47, 11)
  334. .click(0);
  335. });
  336. it('sendKeys: _test', async function() {
  337. await driver.sendKeys('_test');
  338. });
  339. it('click: test ( #desc, 76, 25, 0 )', async function() {
  340. await driver
  341. .sleep(300)
  342. .wait('#desc', 30000)
  343. .sleep(300)
  344. .mouseMove(76, 25)
  345. .click(0);
  346. });
  347. it('sendKeys: _test', async function() {
  348. await driver.sendKeys('_test');
  349. });
  350. it('click: 发布 ( //button[text()="发布"], 41, 15, 0 )', async function() {
  351. await driver
  352. .sleep(300)
  353. .wait('//button[text()="发布"]', 30000)
  354. .sleep(300)
  355. .mouseMove(41, 15)
  356. .click(0);
  357. });
  358. it('click: 确认发布 ( //button[text()="确认发布"], 61, 16, 0 )', async function() {
  359. await driver
  360. .sleep(300)
  361. .wait('//button[text()="确认发布"]', 30000)
  362. .sleep(300)
  363. .mouseMove(61, 16)
  364. .click(0);
  365. });
  366. it('click: 确定 ( //button[text()="确定"], 31, 15, 0 )', async function() {
  367. await driver
  368. .sleep(300)
  369. .wait('//button[text()="确定"]', 30000)
  370. .sleep(300)
  371. .mouseMove(31, 15)
  372. .click(0);
  373. });
  374. it('click: 返回 ( //button[text()="返回"], 25, 6, 0 )', async function() {
  375. await driver
  376. .sleep(300)
  377. .wait('//button[text()="返回"]', 30000)
  378. .sleep(300)
  379. .mouseMove(25, 6)
  380. .click(0);
  381. });
  382. it('scrollElementTo: #viewFramework-product-body, 0, 0', async function() {
  383. await driver
  384. .sleep(300)
  385. .wait('#viewFramework-product-body', 30000)
  386. .sleep(300)
  387. .scrollElementTo(0, 0);
  388. });
  389. it('click: 更多 ( #viewFramework-product-body span:nth-child(9), 19, 12, 0 )', async function() {
  390. await driver
  391. .sleep(300)
  392. .wait('#viewFramework-product-body span:nth-child(9)', 30000)
  393. .sleep(300)
  394. .mouseMove(19, 12)
  395. .click(0);
  396. });
  397. it('click: 历史版本 ( //span[text()="历史版本"], 0, 3, 0 )', async function() {
  398. await driver
  399. .sleep(300)
  400. .wait('//span[text()="历史版本"]', 30000)
  401. .sleep(300)
  402. .mouseMove(0, 3)
  403. .click(0);
  404. });
  405. it('click: 配置列表 ( //div[text()="配置列表"], 120, 36, 0 )', async function() {
  406. await driver
  407. .sleep(300)
  408. .wait('//div[text()="配置列表"]', 30000)
  409. .sleep(300)
  410. .mouseMove(120, 36)
  411. .click(0);
  412. });
  413. it('click: 更多 ( #viewFramework-product-body tr.first > td[type="body"][role="gridcell"].last > div.next-table-cell-wrapper > div > span:nth-child(9), 10, 8, 0 )', async function() {
  414. await driver
  415. .sleep(300)
  416. .wait(
  417. '#viewFramework-product-body tr.first > td[type="body"][role="gridcell"].last > div.next-table-cell-wrapper > div > span:nth-child(9)',
  418. 30000
  419. )
  420. .sleep(300)
  421. .mouseMove(10, 8)
  422. .click(0);
  423. });
  424. it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 163, 21, 0', async function() {
  425. await driver
  426. .sleep(300)
  427. .wait(
  428. 'div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]',
  429. 30000
  430. )
  431. .sleep(300)
  432. .mouseMove(163, 21)
  433. .click(0);
  434. });
  435. it('click: span.next-input > input[role="combobox"], 31, 19, 0', async function() {
  436. await driver
  437. .sleep(300)
  438. .wait('span.next-input > input[role="combobox"]', 30000)
  439. .sleep(300)
  440. .mouseMove(31, 19)
  441. .click(0);
  442. });
  443. it('sendKeys: test', async function() {
  444. await driver.sendKeys('test');
  445. });
  446. it('click: 查询 ( //button[text()="查询"], 8, 25, 0 )', async function() {
  447. await driver
  448. .sleep(300)
  449. .wait('//button[text()="查询"]', 30000)
  450. .sleep(300)
  451. .mouseMove(8, 25)
  452. .click(0);
  453. });
  454. it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 91, 18, 0', async function() {
  455. await driver
  456. .sleep(300)
  457. .wait(
  458. 'div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]',
  459. 30000
  460. )
  461. .sleep(300)
  462. .mouseMove(91, 18)
  463. .click(0);
  464. });
  465. it('sendKeys: test_test', async function() {
  466. await driver.sendKeys('test_test');
  467. });
  468. it('click: 查询 ( //button[text()="查询"], 17, 17, 0 )', async function() {
  469. await driver
  470. .sleep(300)
  471. .wait('//button[text()="查询"]', 30000)
  472. .sleep(300)
  473. .mouseMove(17, 17)
  474. .click(0);
  475. });
  476. it('click: 删除 ( //a[text()="删除"], 7, 8, 0 )', async function() {
  477. await driver
  478. .sleep(300)
  479. .wait('//a[text()="删除"]', 30000)
  480. .sleep(300)
  481. .mouseMove(7, 8)
  482. .click(0);
  483. });
  484. it('click: 确认 ( //button[text()="确认"], 21, 15, 0 )', async function() {
  485. await driver
  486. .sleep(300)
  487. .wait('//button[text()="确认"]', 30000)
  488. .sleep(300)
  489. .mouseMove(21, 15)
  490. .click(0);
  491. });
  492. it('click: 确定 ( //button[text()="确定"], 25, 14, 0 )', async function() {
  493. await driver
  494. .sleep(300)
  495. .wait('//button[text()="确定"]', 30000)
  496. .sleep(300)
  497. .mouseMove(25, 14)
  498. .click(0);
  499. });
  500. function _(str) {
  501. if (typeof str === 'string') {
  502. return str.replace(/\{\{(.+?)\}\}/g, function(all, key) {
  503. return testVars[key] || '';
  504. });
  505. } else {
  506. return str;
  507. }
  508. }
  509. };
  510. if (module.parent && /mocha\.js/.test(module.parent.id)) {
  511. runThisSpec();
  512. }
  513. function runThisSpec() {
  514. // read config
  515. let webdriver = process.env['webdriver'] || '';
  516. let proxy = process.env['wdproxy'] || '';
  517. let config = require(rootPath + '/config.json');
  518. let webdriverConfig = Object.assign({}, config.webdriver);
  519. let host = webdriverConfig.host;
  520. let port = webdriverConfig.port || 4444;
  521. let match = webdriver.match(/([^\:]+)(?:\:(\d+))?/);
  522. if (match) {
  523. host = match[1] || host;
  524. port = match[2] || port;
  525. }
  526. let testVars = config.vars;
  527. let browsers = webdriverConfig.browsers;
  528. browsers = browsers.replace(/^\s+|\s+$/g, '');
  529. delete webdriverConfig.host;
  530. delete webdriverConfig.port;
  531. delete webdriverConfig.browsers;
  532. // read hosts
  533. let hostsPath = rootPath + '/hosts';
  534. let hosts = '';
  535. if (fs.existsSync(hostsPath)) {
  536. hosts = fs.readFileSync(hostsPath).toString();
  537. }
  538. let specName = path
  539. .relative(rootPath, __filename)
  540. .replace(/\\/g, '/')
  541. .replace(/\.js$/, '');
  542. browsers.split(/\s*,\s*/).forEach(function(browserName) {
  543. let caseName = specName + ' : ' + browserName;
  544. let browserInfo = browserName.split(' ');
  545. browserName = browserInfo[0];
  546. let browserVersion = browserInfo[1];
  547. describe(caseName, function() {
  548. this.timeout(600000);
  549. this.slow(1000);
  550. let driver;
  551. before(function() {
  552. let self = this;
  553. let driver = new JWebDriver({
  554. host: host,
  555. port: port,
  556. });
  557. let sessionConfig = Object.assign({}, webdriverConfig, {
  558. browserName: browserName,
  559. version: browserVersion,
  560. 'ie.ensureCleanSession': true,
  561. chromeOptions: {
  562. args: ['--enable-automation'],
  563. },
  564. });
  565. if (proxy) {
  566. sessionConfig.proxy = {
  567. proxyType: 'manual',
  568. httpProxy: proxy,
  569. sslProxy: proxy,
  570. };
  571. } else if (hosts) {
  572. sessionConfig.hosts = hosts;
  573. }
  574. try {
  575. self.driver = driver
  576. .session(sessionConfig)
  577. .windowSize(1024, 768)
  578. .config({
  579. pageloadTimeout: 30000, // page onload timeout
  580. scriptTimeout: 5000, // sync script timeout
  581. asyncScriptTimeout: 10000, // async script timeout
  582. });
  583. } catch (e) {
  584. console.log(e);
  585. }
  586. self.testVars = testVars;
  587. let casePath = path.dirname(caseName);
  588. self.screenshotPath = rootPath + '/screenshots/' + casePath;
  589. self.diffbasePath = rootPath + '/diffbase/' + casePath;
  590. self.caseName = caseName.replace(/.*\//g, '').replace(/\s*[:\.\:\-\s]\s*/g, '_');
  591. mkdirs(self.screenshotPath);
  592. mkdirs(self.diffbasePath);
  593. self.stepId = 0;
  594. return self.driver;
  595. });
  596. module.exports();
  597. beforeEach(function() {
  598. let self = this;
  599. self.stepId++;
  600. if (self.skipAll) {
  601. self.skip();
  602. }
  603. });
  604. afterEach(async function() {
  605. let self = this;
  606. let currentTest = self.currentTest;
  607. let title = currentTest.title;
  608. if (
  609. currentTest.state === 'failed' &&
  610. /^(url|waitBody|switchWindow|switchFrame):/.test(title)
  611. ) {
  612. self.skipAll = true;
  613. }
  614. if (!/^(closeWindow):/.test(title)) {
  615. let filepath = self.screenshotPath + '/' + self.caseName + '_' + self.stepId;
  616. let driver = self.driver;
  617. try {
  618. // catch error when get alert msg
  619. await driver.getScreenshot(filepath + '.png');
  620. let url = await driver.url();
  621. let html = await driver.source();
  622. html = '<!--url: ' + url + ' -->\n' + html;
  623. fs.writeFileSync(filepath + '.html', html);
  624. let cookies = await driver.cookies();
  625. fs.writeFileSync(filepath + '.cookie', JSON.stringify(cookies));
  626. } catch (e) {}
  627. }
  628. });
  629. after(function() {
  630. return this.driver.close();
  631. });
  632. });
  633. });
  634. }
  635. function getRootPath() {
  636. let rootPath = path.resolve(__dirname);
  637. while (rootPath) {
  638. if (fs.existsSync(rootPath + '/config.json')) {
  639. break;
  640. }
  641. rootPath = rootPath.substring(0, rootPath.lastIndexOf(path.sep));
  642. }
  643. return rootPath;
  644. }
  645. function mkdirs(dirname) {
  646. if (fs.existsSync(dirname)) {
  647. return true;
  648. } else {
  649. if (mkdirs(path.dirname(dirname))) {
  650. fs.mkdirSync(dirname);
  651. return true;
  652. }
  653. }
  654. }
  655. function callSpec(name) {
  656. try {
  657. require(rootPath + '/' + name)();
  658. } catch (e) {
  659. console.log(e);
  660. process.exit(1);
  661. }
  662. }
  663. function isPageError(code) {
  664. return (
  665. code == '' ||
  666. / jscontent="errorCode" jstcache="\d+"|diagnoseConnectionAndRefresh|dnserror_unavailable_header|id="reportCertificateErrorRetry"|400 Bad Request|403 Forbidden|404 Not Found|500 Internal Server Error|502 Bad Gateway|503 Service Temporarily Unavailable|504 Gateway Time-out/i.test(
  667. code
  668. )
  669. );
  670. }
  671. function catchError(error) {}