UNPKG

62.8 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Source: HighChart.js</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14</head>
15
16<body>
17
18<div id="main">
19
20 <h1 class="page-title">Source: HighChart.js</h1>
21
22
23
24
25
26
27 <section>
28 <article>
29 <pre class="prettyprint source linenums"><code>(function () {
30 "use strict";
31 /**
32 * Creates new HighChart
33 * @class HighChart
34 */
35 var HighChart = function () {
36 var helper = require("./TestHelper");
37 var TestHelperPO = require("./TestHelperPO");
38 var logger = require("./Logger.js");
39 var fs = require("fs");
40 var Promise = require("bluebird");
41
42 var section, container, svg, tooltip;
43 var EC = protractor.ExpectedConditions;
44 return {
45 /**
46 * set Chart Elements
47 * @method setChartElements
48 * @param {object} sectionElement
49 */
50 setChartElements: function (sectionElement) {
51 section = sectionElement;
52 container = section.element(by.css("div.highcharts-container"));
53 svg = container.element(by.css("svg"));
54 logger.info("chart elements set for section " + sectionElement)
55 },
56 /**
57 * set svg element
58 * @method setSVG
59 * @param {object} svgElement
60 */
61 setSVG: function (svgElement) {
62 svg = svgElement;
63 logger.info("svg element set " + svgElement)
64 },
65 /**
66 * get svg element
67 * @method getSVG
68 * @return {object} svg
69 */
70 getSVG: function () {
71 return svg
72 },
73 /**
74 * set container element
75 * @method setContianer
76 * @param {object} containerElement
77 */
78 setContainer: function (containerElement) {
79 container = containerElement;
80 logger.info("container set " + containerElement)
81 },
82 /**
83 * get container element
84 * @method getContainer
85 * @return {object} container
86 */
87 getContainer: function () {
88 return container
89 },
90 /**
91 * check if chart is displayed
92 * @method isChartDisplayed
93 * @return {boolean}
94 */
95 isChartDisplayed: function () {
96 return svg.isPresent()
97 },
98
99 /**
100 * get text displayed in x-axis or y-axis
101 * @method getAxisText
102 * @param {int} index
103 * @return {string}
104 */
105 getAxisText: function (index) {
106 logger.info("get axis text using index " + index);
107 return this.getAxisTextByIndex(index)
108 },
109
110 /**
111 * get text displayed in x-axis
112 * @method getXaxisText
113 * @return {string}
114 */
115 getXaxisText: function () {
116 logger.info("get x-axis text");
117 return this.getAxisTextByIndex(1)
118 },
119
120 /**
121 * get text displayed in y-axis
122 * @method getYaxisText
123 * @return {string}
124 */
125 getYaxisText: function () {
126 logger.info("get y-axis text");
127 return this.getAxisTextByIndex(2)
128 },
129
130 /**
131 * get text displayed in axis
132 * @method getAxisTextByIndex
133 * @param {int} index (1 for x-axis, 2 for y-axis)
134 * @return {string}
135 */
136 getAxisTextByIndex: function (index) {
137 logger.info("get axis text by index " + index);
138 var deferred = protractor.promise.defer();
139 index = index - 1;
140 this.waitForChartElement("svg g.highcharts-axis");
141 svg = section.element(by.css("svg"));
142 svg.all(by.css("g.highcharts-axis")).filter(function (li, id) {
143 return id === index
144 }).then(function (texts) {
145 if (texts.length === 1) {
146 texts[0].getText().then(function (text) {
147 deferred.fulfill(text)
148 })
149 } else {
150 deferred.reject(new Error("axis text not found for given index!"));
151 logger.info("axis text not found for given index!")
152 }
153 });
154 return deferred.promise
155 },
156
157 /**
158 * get labels displayed in x-axis
159 * @method getXaxisLabels
160 * @return {list}
161 */
162 getXaxisLabels: function () {
163 logger.info("get x-axis labels");
164 return this.getAxisLabels("x")
165 },
166 /**
167 * get labels displayed in y-axis
168 * @method getYaxisLabels
169 * @return {list}
170 */
171 getYaxisLabels: function () {
172 logger.info("get y-axis labels");
173 return this.getAxisLabels("y")
174 },
175 /**
176 * get labels displayed in x-axis or y-axis
177 * @param axis
178 * @method getAxisLabels
179 * @return {list}
180 */
181 getAxisLabels: function (axis, index) {
182 logger.info("get axis labels");
183 var deferred = protractor.promise.defer();
184
185 function querytext(x, y) {
186 return new Promise(function (resolve, reject) {
187 resolve(robot.moveMouse(x, y))
188 })
189 }
190
191 if (index === undefined)index = 0; else index = index - 1;
192 var txtList = svg.all(by.css("svg g.highcharts-" + axis + "axis-labels")).get(index);
193 txtList.all(by.css("text")).then(function (list) {
194 var items = new Array;
195 list.forEach(function (li, index) {
196 li.getText().then(function (text) {
197 if (text.trim().length > 0) {
198 items.push(text)
199 }
200 })
201 });
202 return items
203 }).then(function (items) {
204 if (items.length > 0)deferred.fulfill(items); else {
205 deferred.reject(new Error(axis + "-axis labels list is empty!"));
206 logger.info(axis + "-axis labels list is empty!")
207 }
208 });
209 return deferred.promise
210 },
211 /**
212 * get legends displayed in section (outside svg element)
213 * @method getLegendsFromSection
214 * @return {list}
215 */
216 getLegendsFromSection: function () {
217 logger.info("get legends from section div");
218 var deferred = protractor.promise.defer();
219 this.waitForChartElement("div.highcharts-legend-item");
220 section.all(by.css("div.highcharts-legend-item")).then(function (list) {
221 var items = new Array;
222 list.forEach(function (item, index) {
223 item.getText().then(function (text) {
224 items.push(text)
225 })
226 });
227 return items
228 }).then(function (legends) {
229 if (legends.length > 0)deferred.fulfill(legends); else deferred.reject("No legends!")
230 });
231 return deferred.promise
232 },
233
234 /** get highchart data in highchart demo website based on the tooltip
235 * @method getChartData
236 * @parameter index_data if set to null it will return the whole data for the highcharts
237 * if it is not null, it will check whehther the tooltipdata exit in the highchart,
238 * the mouse will stay on that point if fount it.
239 * @return the whole data string and also save the data in csv file.
240 * */
241 getChartData: function (index_data) {
242 var deferred = protractor.promise.defer();
243 if (process.env.highchart === "true") {
244 logger.info("get data from section svg");
245 robot.setMouseDelay(0);
246 function querytext(x, y) {
247 return new Promise(function (resolve, reject) {
248 resolve(robot.moveMouse(x, y))
249 })
250 }
251
252 return TestHelperPO.isElementPresent(element(by.xpath('//*[@id="menu-second"]/ul/li[1]/a'))).then(function () {
253 var mouse = robot.getMousePos();
254 console.log("Mouse is at x:" + mouse.x + " y:" + mouse.y);
255 var screenSize = robot.getScreenSize();
256 var width = screenSize.width;
257 var text_results = new Array;
258 var items = new Array;
259 var ind = index_data;
260
261 function querylist() {
262 return new Promise(function (resolve, reject) {
263 resolve(svg.all(by.css("g.highcharts-tooltip")).then(function (list) {
264 if (typeof list != "undefined" &amp;&amp; list) {
265 console.log("list: " + list);
266 console.log("list length: " + list.length);
267 list[0].getText().then(function (text) {
268 if (typeof text != "undefined" &amp;&amp; text) {
269 console.log("in get tooltip 4");
270 list[0].getText().then(function (text) {
271 console.log("in get tooltip 5" + text);
272 var result = text.replace(/,\s/g, " ");
273 result = result.replace(/[^\w\s("|,|:|(.\d)|-]/g, "");
274 items.push(result);
275 console.log("text is" + text);
276 console.log("index_data is" + ind);
277 if (result.toString() === ind.toString()) {
278 browser.sleep(3e3).then(function () {
279 deferred.fulfill(true);
280 return deferred.promise
281 })
282 }
283 }).catch(function (error) {
284 console.log("error in querrylist 1:" + error)
285 })
286 } else {
287 throw new Error("oh no! text is null")
288 }
289 })
290 } else {
291 throw new Error("oh no! list is null")
292 }
293 }))
294 })
295 }
296
297 console.log("w: " + width);
298 var step = function (i, done) {
299 console.log("I start is: " + i);
300 if (i &lt;= width) {
301 console.log("i is: " + i + "width is: " + width);
302 querytext(i, 350).then(function () {
303 querylist().then(function (text) {
304 if (typeof text != "undefined" &amp;&amp; text) {
305 console.log("text is:" + text);
306 console.log("I in queryList: " + i)
307 }
308 step(i + 1)
309 }).catch(function (error) {
310 console.log("error in svg all:" + error);
311 step(i + 1)
312 })
313 })
314 } else {
315 console.log("should not print");
316 var uniqueArray = items.filter(function (elem, pos) {
317 return items.indexOf(elem) == pos
318 });
319 var datetime = new Date;
320 var res_string = uniqueArray.join();
321 res_string = res_string.replace(/,/g, "\n");
322 fs.writeFile("./testchartdata" + datetime + ".csv", res_string, function (err) {
323 if (err)console.log(err); else {
324 deferred.fulfill(res_string)
325 }
326 })
327 }
328 console.log("Test")
329 };
330 step(330);
331 console.log("post for loop");
332 return deferred.promise
333 })
334 }
335 else {
336 logger.info("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
337 console.log("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
338 throw new Error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'")
339 }
340 },
341
342 /** get apm chart data based on the tooltip
343 * @method getChartData
344 * @parameter startx the start x position for mouse to start
345 * starty the start y position for mouse to start
346 * endx the end x position will be screenwidth-endx
347 * index_data if set to null it will return the whole data for the highcharts
348 * if it is not null, it will check whehther the tooltipdata exit in the highchart,
349 * the mouse will stay on that point if fount it
350 * rollrange the scroll range for page
351 * rolldirection the scroll direction for page
352 * @return the whole data string and also save the data in csv file.
353 * */
354 getApmChartData: function (startx, starty, endx, index_data, rollrange, rolldirection) {
355 var deferred = protractor.promise.defer();
356 console.log("Here is the value for highchart: "+process.env.highchart);
357 if (process.env.highchart === "true") {
358 var robot = require("robotjs");
359 logger.info("get data from section svg");
360 robot.setMouseDelay(0);
361 function querytext(x, y) {
362 return new Promise(function (resolve, reject) {
363 resolve(robot.moveMouse(x, y))
364 })
365 }
366
367 return TestHelperPO.isElementPresent(element(by.xpath('//*[@id="highcharts-0"]'))).then(function () {
368 var mouse = robot.getMousePos();
369 var screenSize = robot.getScreenSize();
370 var width = screenSize.width;
371 var text_results = new Array;
372 var items = new Array;
373 var tooltip = container.element(by.css("div.highcharts-tooltip"));
374
375 function querylist() {
376 return new Promise(function (resolve, reject) {
377 resolve(tooltip.all(by.css("span")).then(function (list) {
378 if (typeof list != "undefined" &amp;&amp; list) {
379 list[0].getText().then(function (text) {
380 if (typeof text != "undefined" &amp;&amp; text) {
381 list[0].getText().then(function (text) {
382 var editdata = text.split("\n");
383 var editdata_1 = editdata.join();
384 editdata = editdata_1 + "\n";
385 items.push(editdata);
386 if (editdata_1.toString() === index_data.toString()) {
387 browser.sleep(3e3).then(function () {
388 items = [];
389 items.push(true)
390 })
391 } else {
392 var int_1 = string_1.replace(/\.[0-9]\d*/g, " ");
393 var int_2 = string_2.replace(/\.[0-9]\d*/g, " ");
394 int_1 = int_1.toString();
395 int_2 = int_2.toString();
396 if (int_1 != null &amp;&amp; int_2 != null &amp;&amp; int_1.valueOf() === int_2.valueOf()) {
397 browser.sleep(3e3).then(function () {
398 items = [];
399 items.push(true)
400 })
401 }
402 }
403 })
404 }
405 })
406 }
407 }))
408 })
409 }
410
411 console.log("w: " + width);
412 querytext(startx, starty).then(function () {
413 robot.mouseClick();
414 if(rollrange != null &amp;&amp; rolldirection != null)
415 robot.scrollMouse(rollrange, rolldirection)
416 });
417 var step = function (i, done) {
418 if (i &lt;= width - endx) {
419 querytext(i, starty).then(function () {
420 querylist().then(function () {
421 if (typeof items[0] === "boolean") {
422 deferred.fulfill(items[0]);
423 return deferred.promise;
424 i = width
425 } else {
426 step(i + 1)
427 }
428 }).catch(function (error) {
429 step(i + 1)
430 })
431 })
432 } else {
433 var uniqueArray = items.filter(function (elem, pos) {
434 return items.indexOf(elem) == pos
435 });
436 var result = uniqueArray.join(" ");
437 fs.writeFile("./testcharhhihiiktdata.csv", result, function (err) {
438 if (err)console.log(err); else {
439 deferred.fulfill(result)
440 }
441 })
442 }
443 };
444 step(startx);
445 return deferred.promise
446 })
447 }
448 else {
449 logger.info("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
450 console.error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
451 throw new Error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'")
452 }
453 },
454 /** get BM chart data based on the tooltip
455 * @method getBMChartData
456 * @parameter startx the start x position for mouse to start
457 * starty the start y position for mouse to start
458 * endx the end x position will be screenwidth-endx
459 * index_data if set to null it will return the whole data for the highcharts
460 * if it is not null, it will check whehther the tooltipdata exit in the highchart,
461 * the mouse will stay on that point if fount it
462 * rollrange the scroll range for page
463 * rolldirection the scroll direction for page
464 * @return the whole data string and also save the data in csv file.
465 * */
466 getBMChartData: function (startx, starty, endx, index_data, rollrange, rolldirection) {
467 var deferred = protractor.promise.defer();
468 console.log("Here is the value for highchart: " + process.env.highchart);
469 if (process.env.highchart === "true") {
470 var robot = require("robotjs");
471 logger.info("get data from section svg");
472 robot.setMouseDelay(0);
473 function querytext(x, y) {
474 return new Promise(function (resolve, reject) {
475 console.log("moving the mouse")
476 resolve(robot.moveMouse(x, y))
477 })
478 }
479 // console.log("I need to get High Chart : ");
480 return TestHelperPO.isElementPresent(element(by.css('#container > div.highcharts-container'))).then(function () {
481 var mouse = robot.getMousePos();
482 var screenSize = robot.getScreenSize();
483 var width = screenSize.width;
484 console.log("width is "+width)
485 var text_results = new Array;
486 var items = new Array;
487 var tooltip = container.element(by.css("g.highcharts-tooltip"));
488
489 function querylist() {
490 return new Promise(function (resolve, reject) {
491 resolve(tooltip.all(by.css("tspan")).then(function (list) {
492 //console.log("list is" +list)
493 if (typeof list != "undefined" &amp;&amp; list) {
494 tooltip.getText().then(function (text) {
495 if (typeof text != "undefined" &amp;&amp; text) {
496 //list.getText().then(function (text) {
497 var editdata = text.split("\n");
498 var editdata_1 = editdata.join();
499 editdata = editdata_1 + "\n";
500 console.log("list length is "+list.length);
501 editdata = editdata.replace(/\d+/g, '$&amp;,');
502 console.log("editdata is : "+editdata)
503 items.push(editdata);
504 if (editdata_1.toString() === index_data.toString()) {
505 browser.sleep(3e3).then(function () {
506 items = [];
507 items.push(true)
508 })
509 } else {
510 var int_1 = string_1.replace(/\.[0-9]\d*/g, " ");
511 var int_2 = string_2.replace(/\.[0-9]\d*/g, " ");
512 int_1 = int_1.toString();
513 int_2 = int_2.toString();
514 if (int_1 != null &amp;&amp; int_2 != null &amp;&amp; int_1.valueOf() === int_2.valueOf()) {
515 browser.sleep(3e3).then(function () {
516 items = [];
517 items.push(true)
518 })
519 }
520 }
521 //})
522 }
523 })
524
525
526 }
527 }))
528 })
529 }
530
531 console.log("w: " + width);
532 querytext(startx, starty).then(function () {
533 robot.mouseClick();
534 console.log("Here is the start")
535 console.log("rollrange is "+rollrange)
536 console.log("rolldirection is " +rolldirection)
537 //robot.scrollMouse(rollrange, rolldirection)
538 });
539 var step = function (i, done) {
540 if (i &lt;= width - endx) {
541 console.log("into step"+ i)
542 querytext(i, starty).then(function () {
543 querylist().then(function () {
544 if (typeof items[0] === "boolean") {
545 deferred.fulfill(items[0]);
546 return deferred.promise;
547 i = width
548 } else {
549 step(i + 10)
550 }
551 }).catch(function (error) {
552 step(i + 10)
553 })
554 })
555 } else {
556 var uniqueArray = items.filter(function (elem, pos) {
557 return items.indexOf(elem) == pos
558 });
559 var result = uniqueArray.join(" ");
560 fs.writeFile("./testcharhhihiiktdata.csv", result, function (err) {
561 if (err)console.log(err); else {
562 deferred.fulfill(result)
563 }
564 })
565 }
566 };
567 step(startx);
568 return deferred.promise
569 })
570 } else {
571 logger.info("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
572 console.error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
573 throw new Error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'")
574 }
575 },
576 /** get OO chart data based on the tooltip
577 * @method getOOChartData
578 * @parameter time_stamp, the time you want to get the tooltip data, it can be a single time or a time range
579 * seperated by comma i.e."Monday,Thursday" which means Monday to Friday
580 * loopTime, the maximam loop time for user to find the time stamp, if the program does not find
581 * the time stamp after the maximum loopTimes it will quit.
582 * startx, the start x pixel value for the mouse to start
583 * starty, the start y pixel value for the mouse to start
584 * endx, the mouse will move horizontally, the endx is the pixel value to the right edge of
585 * the screen
586 * rollrange the scroll range for page
587 * rolldirection the scroll direction for page
588 * @return the whole data string and also save the data in csv file.
589 * */
590
591 getOOChartData: function (time_stamp, loopTime, startx, starty, endx, rollrange, rolldirection) {
592 var deferred = protractor.promise.defer();
593 if (process.env.highchart === "true") {
594 logger.info("get data from section svg");
595 time_stamp = time_stamp.split(",");
596 robot.setMouseDelay(0);
597 function querytext(x, y) {
598 return new Promise(function (resolve, reject) {
599 resolve(robot.moveMouse(x, y))
600 })
601 }
602
603 return TestHelperPO.isElementPresent(element(by.xpath('//*[@id="r2d1"]/div/section'))).then(function () {
604 var mouse = robot.getMousePos();
605 var screenSize = robot.getScreenSize();
606 var width = screenSize.width;
607 var text_results = new Array;
608 var items = new Array;
609 var found = new Array;
610 var loopcount = 0;
611 var tooltip = container.element(by.css("div.highcharts-tooltip"));
612
613 function querylist() {
614 return new Promise(function (resolve, reject) {
615 resolve(tooltip.all(by.css("span")).then(function (list) {
616 if (typeof list != "undefined" &amp;&amp; list) {
617 list[0].getText().then(function (text) {
618 if (typeof text != "undefined" &amp;&amp; text) {
619 list[0].getText().then(function (text) {
620 var editdata = text.split("\n");
621 editdata[3] = editdata[3].replace(/,/g, " ");
622 var temptagtime = (editdata[2] + editdata[3]).toString();
623 editdata = (editdata[0] + " " + editdata[1]).toString() + "," + (editdata[2] + editdata[3]).toString();
624 editdata += "\n";
625 items.push(editdata);
626 if (temptagtime == time_stamp[0] || temptagtime == time_stamp[1] || loopcount === loopTime) {
627 found.push(true)
628 }
629 })
630 }
631 })
632 }
633 }))
634 })
635 }
636
637 querytext(300, 450).then(function () {
638 robot.mouseClick();
639 robot.scrollMouse(rollrange, rolldirection)
640 });
641 var step = function (i, done) {
642 if (i &lt;= width - endx) {
643 querytext(i, starty).then(function () {
644 querylist().then(function () {
645 if (found[0] === true) {
646 var uniqueArray = items.filter(function (elem, pos) {
647 return items.indexOf(elem) == pos
648 });
649 var result = uniqueArray.join(" ");
650 fs.writeFile("./testOOhighchartdata.csv", result, function (err) {
651 if (err)console.log(err); else {
652 deferred.fulfill(result)
653 }
654 })
655 } else {
656 step(i + 1)
657 }
658 }).catch(function (error) {
659 step(i + 1)
660 })
661 })
662 } else {
663 loopcount++;
664 step(startx)
665 }
666 };
667 step(startx);
668
669 })
670 }
671 else {
672 logger.info("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
673 console.error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
674 throw new Error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
675 }
676 },
677
678 /** get the tooltip information for apmhighchart
679 * @method getTooltipInfo
680 * @parameter Timestamp, the timerange you want to get for the tooltip, if set to null will print no data.
681 * Tagname, the tagname or tagname list you want to get for highchart, if set to null,
682 * will print all tag
683 * startx, the start x pixel value for the mouse to start
684 * starty, the start y pixel value for the mouse to start
685 * endx, the mouse will move horizontally, the endx is the pixel value to the right edge of
686 * the screen
687 * rollrange the scroll range for page
688 * rolldirection the scroll direction for page
689 * needVerify, if set to true, it will verify the tagname exits in the tooltip,
690 * return ture if the tag exit and
691 * return false if the tag is not exit
692 * if set to false, it will return the value under the tag name,
693 * if the tag does not exit, it will put "no data" under that tag
694 */
695 getTooltipInfo: function (Timestamp, Tagname, needVerify, startx, starty, endx, rollrange, rolldirection) {
696 var deferred = protractor.promise.defer();
697 if (process.env.highchart === "true") {
698 logger.info("get data from section svg");
699 console.log("rollrange" + rollrange);
700 console.log("rolldirection" + rolldirection);
701 robot.setMouseDelay(0);
702 function querytext(x, y) {
703 return new Promise(function (resolve, reject) {
704 resolve(robot.moveMouse(x, y))
705 })
706 }
707
708 function scrollpage(x, y) {
709 return new Promise(function (resolve, reject) {
710 resolve(robot.scrollMouse(x, y))
711 })
712 }
713
714 scrollpage(rollrange, rolldirection);
715 if (!Timestamp || 0 === Timestamp.length) {
716 Timestamp = " "
717 }
718 if (!Tagname || 0 === Tagname.length) {
719 Tagname = " "
720 }
721 var timevalue = Timestamp.split(",");
722 var tagvaule = Tagname.split(",");
723 var timeindex = 0;
724 return TestHelperPO.isElementPresent(element(by.xpath('//*[@id="highcharts-0"]'))).then(function () {
725 var mouse = robot.getMousePos();
726 var screenSize = robot.getScreenSize();
727 var width = screenSize.width;
728 var text_results = new Array;
729 var items = new Array;
730 var tooltip = container.element(by.css("div.highcharts-tooltip"));
731
732 function querylist() {
733 return new Promise(function (resolve, reject) {
734 resolve(tooltip.all(by.css("span")).then(function (list) {
735 if (typeof list != "undefined" &amp;&amp; list) {
736 list[0].getText().then(function (text) {
737 if (typeof text != "undefined" &amp;&amp; text) {
738 list[0].getText().then(function (text) {
739 if (timeindex &lt; 2) {
740 var res = new Array;
741 var editdata = text.split("\n");
742 res.push(editdata[0].toString());
743 if (timevalue.length > 1 &amp;&amp; timeindex > 0 || editdata[0].toString() === timevalue[timeindex].toString()) {
744 browser.sleep(1e3).then(function () {
745 var getValue = function (m, j) {
746 if (m &lt; editdata.length &amp;&amp; j &lt; tagvaule.length) {
747 var insideloop = function (m) {
748 var temptag = editdata[m].split(":");
749 if (temptag[0].toString() === tagvaule[j].toString()) {
750 res.push(temptag[1].toString());
751 getValue(1, j + 1)
752 } else {
753 if (m === editdata.length - 1) {
754 if (needVerify === false) {
755 var missingtag = "no data";
756 res.push(missingtag);
757 getValue(1, j + 1)
758 } else {
759 items = [];
760 items.push(false)
761 }
762 } else {
763 getValue(m + 1, j)
764 }
765 }
766 };
767 insideloop(m)
768 } else {
769 if (needVerify === false) {
770 items.push(res.join());
771 if (editdata[0].toString() === timevalue[timeindex].toString()) {
772 timeindex++;
773 return items
774 }
775 } else {
776 items = [];
777 items.push(true)
778 }
779 }
780 };
781 getValue(1, 0)
782 })
783 }
784 }
785 })
786 }
787 })
788 }
789 }))
790 })
791 }
792
793 querytext(300, 450).then(function () {
794 robot.mouseClick()
795 });
796 var step = function (i, done) {
797 if (i &lt;= width - endx) {
798 querytext(i, starty).then(function () {
799 querylist().then(function () {
800 if (typeof items[0] === "boolean") {
801 deferred.fulfill(items[0]);
802 return deferred.promise;
803 i = width
804 } else if (needVerify === false &amp;&amp; timeindex === timevalue.length) {
805 var uniqueArray = items.filter(function (elem, pos) {
806 return items.indexOf(elem) == pos
807 });
808 deferred.fulfill(uniqueArray);
809 return deferred.promise;
810 i = width
811 } else {
812 step(i + 1)
813 }
814 }).catch(function (error) {
815 step(i + 1)
816 })
817 })
818 } else {
819 var uniqueArray = items.filter(function (elem, pos) {
820 return items.indexOf(elem) == pos
821 });
822 var result = uniqueArray.join(" ");
823 fs.writeFile("./testcharhhihiiktdata.csv", result, function (err) {
824 if (err)console.log(err); else {
825 deferred.fulfill(items)
826 }
827 })
828 }
829 };
830 step(startx);
831 return deferred.promise
832 })
833 }
834 else {
835 logger.info("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
836 console.log("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'");
837 throw new Error("Highchart disabled. Please enable highchart in .env to use functions. Make 'highchart=true'")
838 }
839 },
840
841 /** compare the data with the data in the file line by line with only the integer part
842 * @method compareData
843 * @parameter testdata, the string of the data you get
844 ordfile, the path for the file that contains data
845 * @return boolean value if the similarity is over 95% then true, else false
846 */
847 compareData: function (testdata, orgfile) {
848 var deferred = protractor.promise.defer();
849 console.log("type of testdata " + typeof testdata);
850 testdata = testdata.toString();
851 console.log("type of testdata " + typeof testdata);
852 fs.readFile(orgfile, "utf8", function (err, contents) {
853 if (err)throw err;
854 var arr_now = testdata.split("\n");
855 var arr_org = contents.split("\n");
856 var count = 0;
857 for (var i = 0, j = 0; i &lt; arr_now.length &amp;&amp; j &lt; arr_org.length;) {
858 var string_1 = arr_now[i].toString().trim();
859 var string_2 = arr_org[j].toString().trim();
860 if (string_1.valueOf() === string_2.valueOf()) {
861 count++;
862 i++;
863 j++;
864 continue
865 } else {
866 var int_1 = string_1.replace(/\.[0-9]\d*/g, " ");
867 var int_2 = string_2.replace(/\.[0-9]\d*/g, " ");
868 int_1 = int_1.toString();
869 int_2 = int_2.toString();
870 if (int_1 != null &amp;&amp; int_2 != null &amp;&amp; int_1.valueOf() === int_2.valueOf()) {
871 count++;
872 i++;
873 j++;
874 continue
875 } else {
876 console.log("int_1 is " + int_1);
877 console.log("int_2 is " + int_2);
878 i++;
879 j++;
880 continue
881 }
882 }
883 }
884 var res = count / arr_org.length;
885 console.log("res is " + res);
886 console.log("count is " + count);
887 if (res >= .9) {
888 deferred.fulfill(true)
889 } else {
890 deferred.fulfill(false)
891 }
892 });
893 return deferred.promise
894 },
895 getLegendsFromSVG: function () {
896 logger.info("get legends from section svg");
897 var deferred = protractor.promise.defer();
898 this.waitForChartElement("svg g.highcharts-legend-item");
899 svg.all(by.css("g.highcharts-legend-item")).then(function (list) {
900 var items = new Array;
901 list.forEach(function (item, index) {
902 item.getText().then(function (text) {
903 items.push(text);
904 deferred.fulfill(items)
905 })
906 })
907 });
908 return deferred.promise
909 },
910
911 getParallelAxiesOrder: function () {
912 var deferred = protractor.promise.defer();
913 logger.info("get parallel axies order from left to right");
914 this.waitForChartElement(element.all("#chartSVG > g:nth-child(2) > g").get(1));
915 var axises = element.all(by.css("#chartSVG > g:nth-child(2) > g"));
916 axises.count().then(function (len) {
917 console.log("axises length is" + len)
918 var i = 0;
919 var res = new Array()
920 var step = function (i, done) {
921 if (i &lt; len - 1) {
922 var curaxis = axises.get(i)
923 curaxis.getAttribute("transform").then(function (translate) {
924 console.log(" I am here")
925 var temp = new Array();
926 translate = translate.toString()
927 console.log("translate is " + translate)
928 var start = translate.indexOf("(")
929 console.log("start is " + start)
930 var end = translate.indexOf(")")
931 console.log("end is " + end)
932 var numbers_string = translate.substring(start + 1, end)
933 var x = Number(numbers_string.split(",")[0])
934 console.log("x is " + x)
935 element.all(by.css('#chartSVG > g:nth-child(2) > g #message')).get(i).getInnerHtml().then(function (text) {
936 //console.log("text is " + text)
937 var atext = text.toString();
938 //console.log("atext is " + atext)
939 var btext = atext.replace(/&lt;.*>/g, "");
940 //console.log("btext is " + btext)
941 temp.push(x)
942 temp.push(btext)
943 res.push(temp)
944 step(i + 1)
945 //})
946 })
947
948 })
949 // })
950 } else {
951 var sortedRes = res.sort(function (a, b) {
952 return a[0] - b[0];
953 });
954 deferred.fulfill(sortedRes);
955 }
956
957 };
958 step(0)
959
960 })
961 return deferred.promise
962 },
963
964 verifyParellelTimerangecoverall: function(){
965 var deferred = protractor.promise.defer();
966 logger.info("get parallel axies order from left to right");
967 this.waitForChartElement(element.all("#chartSVG > g:nth-child(2) > g").last());
968 var axises = element.all(by.css("#chartSVG > g:nth-child(2) > g"));
969 var brush = element(by.css("#chartSVG > g:nth-child(2) > g > rect.overlay"));
970 var res;
971 brush.getAttribute("x").then(function(start){
972 console.log("start "+ start)
973 var select_range = element(by.css("#chartSVG > g:nth-child(2) > g > rect.selection"))
974 select_range.getAttribute("x").then(function(start_position){
975 if(start == start_position){
976 brush.getAttribute("width").then(function(length){
977 console.log("end_position "+ length)
978 var select_range = element(by.css("#chartSVG > g:nth-child(2) > g > rect.selection"))
979 select_range.getAttribute("width").then(function(end_position){
980 if(length == end_position){
981 deferred.fulfill(false)
982 }
983 })
984 })
985 }else{
986 deferred.fulfill(false)
987 }
988 })
989 })
990 return deferred.promise
991
992 },
993 waitForChartElement: function (element) {
994 browser.wait(EC.presenceOf(section.element(by.css(element))), 6e4)
995 }
996 }
997 };
998 module.exports = new HighChart
999})();</code></pre>
1000 </article>
1001 </section>
1002
1003
1004
1005
1006</div>
1007
1008<nav>
1009 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="HighChart.html">HighChart</a></li><li><a href="PxDataTable.html">PxDataTable</a></li><li><a href="RestHelper.html">RestHelper</a></li><li><a href="TestHelper.html">TestHelper</a></li></ul><h3>Global</h3><ul><li><a href="global.html#acceptAlert">acceptAlert</a></li><li><a href="global.html#alertIsPresent">alertIsPresent</a></li><li><a href="global.html#assertEqual">assertEqual</a></li><li><a href="global.html#assertInclude">assertInclude</a></li><li><a href="global.html#assertTrue">assertTrue</a></li><li><a href="global.html#clearFilter">clearFilter</a></li><li><a href="global.html#compareData">compareData</a></li><li><a href="global.html#createTestcase">createTestcase</a></li><li><a href="global.html#createTestcaseResult">createTestcaseResult</a></li><li><a href="global.html#createTestPlan">createTestPlan</a></li><li><a href="global.html#dismissAlert">dismissAlert</a></li><li><a href="global.html#dragAndDrop">dragAndDrop</a></li><li><a href="global.html#dragAndDrop2">dragAndDrop2</a></li><li><a href="global.html#elementToBeClickable">elementToBeClickable</a></li><li><a href="global.html#elementToBeSelected">elementToBeSelected</a></li><li><a href="global.html#executeDeleteRequest">executeDeleteRequest</a></li><li><a href="global.html#executeGetRequest">executeGetRequest</a></li><li><a href="global.html#executePatchRequest">executePatchRequest</a></li><li><a href="global.html#executePostRequest">executePostRequest</a></li><li><a href="global.html#executePutRequest">executePutRequest</a></li><li><a href="global.html#geSSOLogin">geSSOLogin</a></li><li><a href="global.html#getAccessToken">getAccessToken</a></li><li><a href="global.html#getAttribute">getAttribute</a></li><li><a href="global.html#getAxisLabels">getAxisLabels</a></li><li><a href="global.html#getAxisText">getAxisText</a></li><li><a href="global.html#getAxisTextByIndex">getAxisTextByIndex</a></li><li><a href="global.html#getBMChartData">getBMChartData</a></li><li><a href="global.html#getCellElement">getCellElement</a></li><li><a href="global.html#getCellElements">getCellElements</a></li><li><a href="global.html#getCellElementText">getCellElementText</a></li><li><a href="global.html#getCellHtml">getCellHtml</a></li><li><a href="global.html#getCellText">getCellText</a></li><li><a href="global.html#getChartData">getChartData</a></li><li><a href="global.html#getColumnCount">getColumnCount</a></li><li><a href="global.html#getColumnElementValues">getColumnElementValues</a></li><li><a href="global.html#getColumnHeaderElements">getColumnHeaderElements</a></li><li><a href="global.html#getColumnHtmlValues">getColumnHtmlValues</a></li><li><a href="global.html#getColumnindex">getColumnindex</a></li><li><a href="global.html#getColumnNames">getColumnNames</a></li><li><a href="global.html#getColumnTextValues">getColumnTextValues</a></li><li><a href="global.html#getContainer">getContainer</a></li><li><a href="global.html#getCssValue">getCssValue</a></li><li><a href="global.html#getCurrentPage">getCurrentPage</a></li><li><a href="global.html#getElementManager">getElementManager</a></li><li><a href="global.html#getFilter">getFilter</a></li><li><a href="global.html#getLegendsFromSection">getLegendsFromSection</a></li><li><a href="global.html#getObjectRef">getObjectRef</a></li><li><a href="global.html#getOOChartData">getOOChartData</a></li><li><a href="global.html#getRandomString">getRandomString</a></li><li><a href="global.html#getRowCount">getRowCount</a></li><li><a href="global.html#getRowElementValues">getRowElementValues</a></li><li><a href="global.html#getRowHtmlValues">getRowHtmlValues</a></li><li><a href="global.html#getRowPerPageValue">getRowPerPageValue</a></li><li><a href="global.html#getRowTextValues">getRowTextValues</a></li><li><a href="global.html#getSVG">getSVG</a></li><li><a href="global.html#getText">getText</a></li><li><a href="global.html#getTooltipInfo">getTooltipInfo</a></li><li><a href="global.html#getUSTSRef">getUSTSRef</a></li><li><a href="global.html#getXaxisLabels">getXaxisLabels</a></li><li><a href="global.html#getXaxisText">getXaxisText</a></li><li><a href="global.html#getYaxisLabels">getYaxisLabels</a></li><li><a href="global.html#getYaxisText">getYaxisText</a></li><li><a href="global.html#goToNextPage">goToNextPage</a></li><li><a href="global.html#goToPage">goToPage</a></li><li><a href="global.html#goToPreviousPage">goToPreviousPage</a></li><li><a href="global.html#iFrameSwitch">iFrameSwitch</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#isChartDisplayed">isChartDisplayed</a></li><li><a href="global.html#isElementNotPresent">isElementNotPresent</a></li><li><a href="global.html#isElementPresent">isElementPresent</a></li><li><a href="global.html#isElementVisible">isElementVisible</a></li><li><a href="global.html#name">name</a></li><li><a href="global.html#noTestCaseFound">noTestCaseFound</a></li><li><a href="global.html#noTestFolderFound">noTestFolderFound</a></li><li><a href="global.html#onPageLoad">onPageLoad</a></li><li><a href="global.html#onPageStable">onPageStable</a></li><li><a href="global.html#postResults">postResults</a></li><li><a href="global.html#postTest">postTest</a></li><li><a href="global.html#scrollIntoView">scrollIntoView</a></li><li><a href="global.html#sendKeys">sendKeys</a></li><li><a href="global.html#setChartElements">setChartElements</a></li><li><a href="global.html#setContainer">setContainer</a></li><li><a href="global.html#setContianer">setContianer</a></li><li><a href="global.html#setElementManager">setElementManager</a></li><li><a href="global.html#setFilter">setFilter</a></li><li><a href="global.html#setRowPerPageValue">setRowPerPageValue</a></li><li><a href="global.html#setSVG">setSVG</a></li><li><a href="global.html#setup">setup</a></li><li><a href="global.html#skipAngularStability">skipAngularStability</a></li><li><a href="global.html#sortColumn">sortColumn</a></li><li><a href="global.html#teardown">teardown</a></li><li><a href="global.html#TestCaseFound">TestCaseFound</a></li><li><a href="global.html#TestCaseResult">TestCaseResult</a></li><li><a href="global.html#TestFolderFound">TestFolderFound</a></li><li><a href="global.html#textToBePresentInElement">textToBePresentInElement</a></li><li><a href="global.html#textToBePresentInElementValue">textToBePresentInElementValue</a></li><li><a href="global.html#titleContains">titleContains</a></li><li><a href="global.html#titleIs">titleIs</a></li><li><a href="global.html#updateTestCase">updateTestCase</a></li><li><a href="global.html#updateTestCaseResult">updateTestCaseResult</a></li><li><a href="global.html#updateTestSet">updateTestSet</a></li><li><a href="global.html#uploadFile">uploadFile</a></li><li><a href="global.html#UserPermissions">UserPermissions</a></li><li><a href="global.html#waitForAngular">waitForAngular</a></li><li><a href="global.html#waitForCondition">waitForCondition</a></li><li><a href="global.html#waitForElementToDisappear">waitForElementToDisappear</a></li><li><a href="global.html#waitForPromise">waitForPromise</a></li><li><a href="global.html#winston">winston</a></li></ul>
1010</nav>
1011
1012<br class="clear">
1013
1014<footer>
1015 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.1</a> on Mon Oct 30 2017 11:31:46 GMT-0700 (PDT)
1016</footer>
1017
1018<script> prettyPrint(); </script>
1019<script src="scripts/linenumber.js"> </script>
1020</body>
1021</html>