05_creating_dsl.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. let test_utils = require('./test_utils');
  2. let model_building_utils = require('./model_building_utils');
  3. let user = "./users/testuser/";
  4. function get_all_attrs() {
  5. return "[\n" +
  6. " {\n" +
  7. " \"name\": \"int\",\n" +
  8. " \"type\": \"int\",\n" +
  9. " \"default\": 0\n" +
  10. " },\n" +
  11. " {\n" +
  12. " \"name\": \"string\",\n" +
  13. " \"type\": \"string\",\n" +
  14. " \"default\": \"hello\"\n" +
  15. " },\n" +
  16. " {\n" +
  17. " \"name\": \"float\",\n" +
  18. " \"type\": \"float\",\n" +
  19. " \"default\": 0\n" +
  20. " },\n" +
  21. " {\n" +
  22. " \"name\": \"boolean\",\n" +
  23. " \"type\": \"boolean\",\n" +
  24. " \"default\": true\n" +
  25. " },\n" +
  26. " {\n" +
  27. " \"name\": \"code\",\n" +
  28. " \"type\": \"code\",\n" +
  29. " \"default\": \"\"\n" +
  30. " },\n" +
  31. " {\n" +
  32. " \"name\": \"file_html\",\n" +
  33. " \"type\": \"file<*.html>\",\n" +
  34. " \"default\": \"\"\n" +
  35. " },\n" +
  36. " {\n" +
  37. " \"name\": \"map_int_string\",\n" +
  38. " \"type\": \"map<int,string>\"\n" +
  39. " },\n" +
  40. " {\n" +
  41. " \"name\": \"list_int\",\n" +
  42. " \"type\": \"lis<int>\",\n" +
  43. " \"default\": [\n" +
  44. " 1,\n" +
  45. " 2\n" +
  46. " ]\n" +
  47. " },\n" +
  48. " {\n" +
  49. " \"name\": \"enum\",\n" +
  50. " \"type\": \"ENUM(Red,Green,Blue)\"\n" +
  51. " },\n" +
  52. " {\n" +
  53. " \"name\": \"enum2\",\n" +
  54. " \"type\": \"ENUM(Four,Five,Six,Seven)\"\n" +
  55. " }\n" +
  56. "]";
  57. }
  58. function get_all_attrs2() {
  59. return "[\n" +
  60. " {\n" +
  61. " \"name\": \"name\",\n" +
  62. " \"type\": \"string\",\n" +
  63. " \"default\": \"test\"\n" +
  64. " },\n" +
  65. " {\n" +
  66. " \"name\": \"\",\n" +
  67. " \"type\": \"\",\n" +
  68. " \"default\": \"\"\n" +
  69. " }\n" +
  70. "]";
  71. }
  72. let assocs = [
  73. //from, to, name, isContain, out_card, in_card
  74. [0, 1, "testAssoc", false, null, null],
  75. [2, 3, "oneToOne", false,
  76. [{
  77. "dir": "out",
  78. "type": "oneToOne",
  79. "min": "1",
  80. "max": "1"
  81. }],
  82. [{
  83. "dir": "in",
  84. "type": "oneToOne",
  85. "min": "1",
  86. "max": "1"
  87. }]
  88. ],
  89. [4, 5, "ManyToOne", false,
  90. null,
  91. [{
  92. "dir": "in",
  93. "type": "ManyToOne",
  94. "min": "0",
  95. "max": "1"
  96. }]
  97. ],
  98. [6, 7, "Containment", true,
  99. null, null
  100. ],
  101. [8, 8, "self", false,
  102. null, null
  103. ]
  104. ];
  105. module.exports = {
  106. beforeEach: function (client, done) {
  107. client.url('http://localhost:8124/atompm').pause(300).maximizeWindow(done);
  108. },
  109. 'Login': function (client) {
  110. test_utils.login(client);
  111. },
  112. 'Create AS model': function (client) {
  113. let filename = '/Formalisms/__LanguageSyntax__/SimpleClassDiagram/SimpleClassDiagram.umlIcons.metamodel';
  114. test_utils.load_toolbar(client, [filename]);
  115. let classIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/SimpleClassDiagram\\/SimpleClassDiagram\\.umlIcons\\.metamodel\\/ClassIcon";
  116. client.waitForElementPresent(classIcon, 2000, "Check for class icon...");
  117. client.click(classIcon);
  118. let canvas = "#div_canvas";
  119. client.waitForElementPresent(canvas, 1000, "Checking for canvas...");
  120. let test_folder = "autotest";
  121. let name_field = "#tr_name > td:nth-child(2) > textarea";
  122. let num_elements = 0;
  123. //BUILD CLASSES
  124. let start_x = 50;
  125. let x_diff = 350;
  126. let x_coords = [start_x, start_x + x_diff, start_x + 2 * x_diff];
  127. let start_y = 200;
  128. let y_diff = 150;
  129. let y_coords = [start_y, start_y + y_diff, start_y + 2 * y_diff];
  130. let num_classes = x_coords.length * y_coords.length;
  131. num_elements = model_building_utils.create_classes(client, x_coords, y_coords, num_elements);
  132. // SET NAMES FOR CLASSES
  133. for (let i = 0; i < num_classes; i++) {
  134. let class_name = "Class" + String.fromCharCode(65 + i);
  135. let attrs = {};
  136. attrs[name_field] = class_name;
  137. model_building_utils.set_attribs(client, i, attrs);
  138. }
  139. // SET ATTRIBUTES
  140. let class_div = model_building_utils.get_class_div(0);
  141. let attrib_field = "#tr_attributes > td:nth-child(2) > textarea";
  142. client.moveToElement(class_div, 10, 10)
  143. .mouseButtonClick('middle')
  144. .waitForElementPresent("#dialog_btn", 1000, "Editing menu opens")
  145. .clearValue(attrib_field)
  146. .setValue(attrib_field, get_all_attrs())
  147. .click("#dialog_btn")
  148. .waitForElementNotPresent("#dialog_btn", 1000, "Editing menu closes")
  149. .moveToElement(canvas, 0, 100)
  150. .mouseButtonClick('left')
  151. .pause(1000)
  152. ;
  153. let abstract_class = 4;
  154. let class_div2 = model_building_utils.get_class_div(abstract_class);
  155. let attrib_field2 = "#tr_attributes > td:nth-child(2) > textarea";
  156. let checkbox = "#tr_abstract > td:nth-child(2) > input[type=\"checkbox\"]";
  157. client.moveToElement(class_div2, 10, 10)
  158. .mouseButtonClick('middle')
  159. .waitForElementPresent("#dialog_btn", 1000, "Editing menu opens")
  160. .clearValue(attrib_field2)
  161. .setValue(attrib_field2, get_all_attrs2())
  162. .moveToElement(checkbox, 0, 0)
  163. .mouseButtonClick('left')
  164. .click("#dialog_btn")
  165. .waitForElementNotPresent("#dialog_btn", 1000, "Editing menu closes")
  166. .moveToElement(canvas, 0, 100)
  167. .mouseButtonClick('left')
  168. .pause(1000)
  169. ;
  170. //CREATE INHERITANCE
  171. let inheri_classes = [
  172. [abstract_class, abstract_class + 1],
  173. [abstract_class, abstract_class + 3]];
  174. for (let inheri_set of inheri_classes) {
  175. let sup = model_building_utils.get_class_div(inheri_set[0]);
  176. let sub = model_building_utils.get_class_div(inheri_set[1]);
  177. let inheri_relation = "#div_dialog_0 > select > option:nth-child(2)";
  178. //tiny offset to not hit other arrows
  179. let offset = 2 * inheri_set[1];
  180. client
  181. .moveToElement(sub, 50, 50)
  182. .mouseButtonDown('right')
  183. .moveToElement(sup, 50 + offset, 50 + offset)
  184. .mouseButtonUp('right')
  185. .pause(500)
  186. .click(inheri_relation)
  187. .waitForElementPresent("#dialog_btn", 1000, "Inheri menu opens")
  188. .click("#dialog_btn")
  189. .pause(500)
  190. .waitForElementNotPresent("#dialog_btn", 1000, "Inheri menu closes")
  191. .moveToElement(canvas, 0, 100)
  192. .mouseButtonClick('left')
  193. .pause(500)
  194. ;
  195. num_elements++;
  196. }
  197. //SET ASSOCS
  198. client.pause(500);
  199. let assoc_num = 0;
  200. for (let assoc of assocs) {
  201. let from_ele = model_building_utils.get_class_div(assoc[0]);
  202. let to_ele = model_building_utils.get_class_div(assoc[1]);
  203. let name = assoc[2];
  204. let isContain = assoc[3];
  205. let out_card = assoc[4];
  206. let in_card = assoc[5];
  207. let cardinality_field = "#tr_cardinalities > td:nth-child(2) > textarea";
  208. let assoc_div = model_building_utils.get_assoc_div(num_elements);
  209. assoc_num++;
  210. num_elements++;
  211. let assoc_relation = "#div_dialog_0 > select > option:nth-child(1)";
  212. //tiny offset to not hit other arrows
  213. let offset = 2 * assoc[0] + 2 * assoc[1];
  214. client
  215. .moveToElement(from_ele, 20, 20)
  216. .mouseButtonDown('right')
  217. .moveToElement(to_ele, 20 + offset, 20 + offset)
  218. .mouseButtonUp('right')
  219. .pause(500)
  220. .click(assoc_relation)
  221. .waitForElementPresent("#dialog_btn", 1000, "Assoc menu opens")
  222. .click("#dialog_btn")
  223. .pause(500)
  224. .waitForElementNotPresent("#dialog_btn", 1000, "Assoc menu closes")
  225. .moveToElement(canvas, 0, 100)
  226. .mouseButtonClick('left')
  227. .pause(500)
  228. .waitForElementPresent(assoc_div, 1000, "Assoc name present: " + assoc_div);
  229. if (out_card) {
  230. client
  231. .moveToElement(from_ele, 10, 10)
  232. .mouseButtonClick('middle')
  233. .waitForElementPresent("#dialog_btn", 1000, "Out card menu opens")
  234. .clearValue(cardinality_field)
  235. .setValue(cardinality_field, JSON.stringify(out_card))
  236. .click("#dialog_btn")
  237. .waitForElementNotPresent("#dialog_btn", 1000, "Out card menu closes")
  238. .moveToElement(canvas, 0, 100)
  239. .mouseButtonClick('left')
  240. .pause(500);
  241. }
  242. if (in_card) {
  243. client
  244. .moveToElement(to_ele, 10, 10)
  245. .mouseButtonClick('middle')
  246. .waitForElementPresent("#dialog_btn", 1000, "Out card menu opens")
  247. .clearValue(cardinality_field)
  248. .setValue(cardinality_field, JSON.stringify(in_card))
  249. .click("#dialog_btn")
  250. .waitForElementNotPresent("#dialog_btn", 1000, "Out card menu closes")
  251. .moveToElement(canvas, 0, 100)
  252. .mouseButtonClick('left')
  253. .pause(500);
  254. }
  255. client.getElementSize(assoc_div, function (result) {
  256. model_building_utils.move_to_element_ratio(client, assoc_div, 50, 50)
  257. client.mouseButtonClick('middle')
  258. .waitForElementPresent("#dialog_btn", 1000, "Editing assoc name opens")
  259. .clearValue(name_field)
  260. .setValue(name_field, name);
  261. if (isContain) {
  262. let contain_opt = "#tr_linktype > td:nth-child(2) > select > option:nth-child(2)";
  263. client
  264. .moveToElement(contain_opt, 0, 0)
  265. .mouseButtonClick('left');
  266. }
  267. client
  268. .click("#dialog_btn")
  269. .waitForElementNotPresent("#dialog_btn", 1000, "Editing assoc name closes")
  270. .moveToElement(canvas, 0, 100)
  271. .mouseButtonClick('left')
  272. .pause(500);
  273. })
  274. ;
  275. }
  276. //CREATE CONSTRAINT
  277. let constraint_div = model_building_utils.get_element_div("GlobalConstraintIcon", num_elements);
  278. let constraintIcon = "#\\2f Formalisms\\2f __LanguageSyntax__\\2f SimpleClassDiagram\\2f SimpleClassDiagram\\2e umlIcons\\2e metamodel\\2f GlobalConstraintIcon";
  279. client.waitForElementPresent(constraintIcon, 2000, "Check for constraint icon...");
  280. client.click(constraintIcon);
  281. client
  282. .moveToElement(canvas, 100, 150)
  283. .mouseButtonClick('right')
  284. .pause(500)
  285. .waitForElementPresent(constraint_div, 500, "Created class: " + constraint_div);
  286. let pre_create_opt = "#tr_event > td:nth-child(2) > select > option:nth-child(2)";
  287. let code_field = "#tr_code > td:nth-child(2) > textarea";
  288. let constraint_code = "let C_classes = getAllNodes(['Formalisms/__LanguageSyntax__/SimpleClassDiagram/SimpleClassDiagram/umlIcons/ClassIcon']);\n" +
  289. "C_classes.length <= 2;";
  290. client
  291. .moveToElement(constraint_div, 10, 10)
  292. .mouseButtonClick('middle')
  293. .waitForElementPresent("#dialog_btn", 1000, "Constraint menu opens")
  294. .clearValue(name_field)
  295. .setValue(name_field, "max-two-instances")
  296. .moveToElement(pre_create_opt, 0, 0)
  297. .mouseButtonClick('left')
  298. .clearValue(code_field)
  299. .setValue(code_field, constraint_code)
  300. .click("#dialog_btn")
  301. .waitForElementNotPresent("#dialog_btn", 1000, "Constraint menu closes")
  302. .moveToElement(canvas, 0, 100)
  303. .mouseButtonClick('left')
  304. .pause(1000);
  305. //SAVE MODEL
  306. let model_name = "autotest.model";
  307. let folder_name = "autotest";
  308. model_building_utils.save_model(client, folder_name, model_name);
  309. //COMPILE TO ASMM
  310. let metamodel_name = "autotest.metamodel";
  311. model_building_utils.compile_model(client, "AS", folder_name, metamodel_name);
  312. client.pause(500);
  313. },
  314. 'Create CS model': function (client) {
  315. let filename = '/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax.defaultIcons.metamodel';
  316. test_utils.load_toolbar(client, [filename]);
  317. let classIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/IconIcon";
  318. client.waitForElementPresent(classIcon, 2000, "Check for class icon...");
  319. client.click(classIcon);
  320. let canvas = "#div_canvas";
  321. client.waitForElementPresent(canvas, 1000, "Checking for canvas...");
  322. let test_folder = "autotest";
  323. let name_field = "#tr_typename > td:nth-child(2) > textarea";
  324. let num_elements = 0;
  325. //BUILD CLASSES
  326. let icon_type = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/IconIcon\\/";
  327. let start_x = 200;
  328. let x_diff = 250;
  329. let x_coords = [start_x, start_x + x_diff, start_x + 2 * x_diff];
  330. let start_y = 150;
  331. let y_diff = 180;
  332. let y_coords = [start_y, start_y + y_diff, start_y + 2 * y_diff];
  333. let num_classes = x_coords.length * y_coords.length;
  334. num_elements = model_building_utils.create_classes(client, x_coords, y_coords, num_elements, icon_type);
  335. //SET NAMES FOR CLASSES
  336. for (let i = 0; i < num_classes; i++) {
  337. let class_name = "Class" + String.fromCharCode(65 + i) + "Icon";
  338. let attrs = {};
  339. attrs[name_field] = class_name;
  340. model_building_utils.set_attribs(client, i, attrs, icon_type);
  341. }
  342. // BUILD TEXT FOR ICONS
  343. let textIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/TextIcon";
  344. let textType = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/TextIcon\\/";
  345. let textContent_field = "#tr_textContent > td:nth-child(2) > textarea";
  346. client.waitForElementPresent(textIcon, 2000, "Check for text icon...");
  347. client.click(textIcon);
  348. for (let i = 0; i < num_classes; i++) {
  349. let text = "Class" + String.fromCharCode(65 + i);
  350. let textDiv = model_building_utils.build_div(textType, num_elements);
  351. let iconDiv = model_building_utils.build_div(icon_type, i);
  352. let attrs = {};
  353. attrs[textContent_field] = text;
  354. client
  355. .pause(300)
  356. .moveToElement(canvas, 20, 200)
  357. .mouseButtonClick('right')
  358. .pause(500)
  359. .waitForElementPresent(textDiv, 500, "Created text: " + textDiv);
  360. model_building_utils.set_attribs(client, num_elements, attrs, textType);
  361. num_elements++;
  362. client.moveToElement(textDiv, 10, 10)
  363. .mouseButtonClick('left')
  364. .pause(300)
  365. .mouseButtonDown('left')
  366. .pause(300);
  367. model_building_utils.move_to_element_ratio(client, iconDiv, 35, 15);
  368. client.mouseButtonUp('left');
  369. model_building_utils.click_off(client);
  370. //inner link counts as an element
  371. num_elements++;
  372. }
  373. // BUILD SYMBOLS FOR ICONS
  374. let symbols = ["PathIcon", "CircleIcon", "StarIcon", "PolygonIcon", "EllipseIcon", "EllipseIcon", "RectangleIcon", "ImageIcon"];
  375. let getIcon = function (type) {
  376. return "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/" + type;
  377. };
  378. let getType = function (type) {
  379. return "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/" + type + "\\/";
  380. };
  381. for (let i = 0; i < num_classes; i++) {
  382. let currSymbol = symbols[i % symbols.length];
  383. client.waitForElementPresent(getIcon(currSymbol), 2000, "Check for symbol icon...");
  384. client.click(getIcon(currSymbol));
  385. let symbolDiv = model_building_utils.build_div(getType(currSymbol), num_elements);
  386. let iconDiv = model_building_utils.build_div(icon_type, i);
  387. client
  388. .pause(300)
  389. .moveToElement(canvas, 50, 200)
  390. .mouseButtonClick('right')
  391. .pause(1000)
  392. .waitForElementPresent(symbolDiv, 500, "Created symbol: " + symbolDiv);
  393. model_building_utils.click_off(client);
  394. num_elements++;
  395. model_building_utils.move_to_element_ratio(client, symbolDiv, 50, 50);
  396. client
  397. .mouseButtonClick('left')
  398. .pause(300)
  399. .mouseButtonDown('left')
  400. .pause(300);
  401. model_building_utils.move_to_element_ratio(client, iconDiv, 50, 55);
  402. client.pause(300).mouseButtonUp('left');
  403. model_building_utils.click_off(client);
  404. //inner link counts as an element
  405. num_elements++;
  406. }
  407. // BUILD LINKS
  408. let linkIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/LinkIcon";
  409. let linkType = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/LinkIcon\\/";
  410. let link_typename_field = "#tr_typename > td:nth-child(2) > textarea";
  411. let link_y_coords = [];
  412. let link_x_coords = [start_x + 3 * x_diff, start_x + 4 * x_diff];
  413. for (let i = 0; i < assocs.length / 2; i++) {
  414. link_y_coords.push(start_y + i * y_diff);
  415. }
  416. client.waitForElementPresent(linkIcon, 2000, "Check for link icon...");
  417. client.click(linkIcon);
  418. let num_elements_before = num_elements;
  419. model_building_utils.create_classes(client, link_x_coords, link_y_coords, num_elements, linkType);
  420. //SET NAMES FOR LINKS
  421. for (let i = 0; i < assocs.length; i++) {
  422. let link_name = assocs[i][2] + "Link";
  423. let attrs = {};
  424. attrs[link_typename_field] = link_name;
  425. model_building_utils.set_attribs(client, num_elements_before + i, attrs, linkType);
  426. }
  427. //remove unneeded elements
  428. model_building_utils.delete_element(client, model_building_utils.build_div(icon_type, 4));
  429. model_building_utils.delete_element(client, model_building_utils.build_div(linkType, 50));
  430. let folder_name = "autotest";
  431. model_building_utils.save_model(client, folder_name, "autotestCS.model");
  432. model_building_utils.compile_model(client, "CS", folder_name, "autotest.defaultIcons.metamodel");
  433. client.pause(1000);
  434. },
  435. 'Create model': function (client) {
  436. let test_toolbar = '/autotest/autotest.defaultIcons.metamodel';
  437. test_utils.load_toolbar(client, [test_toolbar]);
  438. let class_names = [];
  439. for (let i = 0; i < 9; i++) {
  440. let class_name = "Class" + String.fromCharCode(65 + i) + "Icon";
  441. if (class_name == "ClassEIcon") {
  442. continue; //skip ClassEIcon
  443. }
  444. class_names.push(class_name);
  445. }
  446. //BUILD CLASSES
  447. let class_icon = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e metamodel\\2f ";
  448. let class_type = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2f ";
  449. let start_x = 200;
  450. let x_diff = 300;
  451. let x_coords = [start_x, start_x + x_diff, start_x + 2 * x_diff];
  452. let start_y = 150;
  453. let y_diff = 180;
  454. let y_coords = [start_y, start_y + y_diff, start_y + 2 * y_diff];
  455. let coords = [];
  456. for (let x of x_coords) {
  457. for (let y of y_coords) {
  458. coords.push([x, y]);
  459. }
  460. }
  461. let num_elements = 0;
  462. let element_map = {};
  463. for (let i = 0; i < class_names.length; i++) {
  464. let class_name = class_names[i];
  465. let class_btn = class_icon + class_name;
  466. client.waitForElementPresent(class_btn, 2000, "Check for class icon: " + class_btn);
  467. client.click(class_btn);
  468. let class_div = class_type + class_name + "\\2f ";
  469. let built_class_div = model_building_utils.create_class(client, coords[i][0], coords[i][1], num_elements, class_div);
  470. element_map[class_name] = built_class_div;
  471. num_elements++;
  472. }
  473. model_building_utils.click_off(client);
  474. // BUILD ASSOCIATIONS
  475. for (let assoc of assocs) {
  476. let from_class_name = "Class" + String.fromCharCode(65 + assoc[0]) + "Icon";
  477. let to_class_name = "Class" + String.fromCharCode(65 + assoc[1]) + "Icon";
  478. if (from_class_name == "ClassEIcon") {
  479. from_class_name = "ClassHIcon";
  480. }
  481. if (to_class_name == "ClassEIcon") {
  482. from_class_name = "ClassFIcon";
  483. }
  484. //select the text of the class
  485. let text_div = " > text:nth-child(1)";
  486. let from_class_div = element_map[from_class_name] + text_div;
  487. let to_class_div = element_map[to_class_name] + text_div;
  488. // console.log(from_class_div);
  489. // console.log(to_class_div);
  490. let isContainAssoc = assoc[3];
  491. if (!isContainAssoc) {
  492. model_building_utils.move_to_element_ratio(client, from_class_div, 30, 50);
  493. client.mouseButtonDown('right');
  494. model_building_utils.move_to_element_ratio(client, to_class_div, 70, 50);
  495. client.mouseButtonUp('right').pause(2000);
  496. } else {
  497. model_building_utils.move_to_element_ratio(client, to_class_div, 30, 50);
  498. client.mouseButtonClick('left').pause(500);
  499. client.mouseButtonDown('left');
  500. model_building_utils.move_to_element_ratio(client, from_class_div, 50, 120);
  501. client.mouseButtonUp('left').pause(2000);
  502. }
  503. model_building_utils.click_off(client);
  504. }
  505. // SAVE INSTANCE MODEL
  506. let folder_name = "autotest";
  507. model_building_utils.save_model(client, folder_name, "autotest_instance.model");
  508. client.pause(1000);
  509. },
  510. after: function (client) {
  511. client.end();
  512. },
  513. };