1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Source: TestHelper.js</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
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: TestHelper.js</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 | <article>
|
29 | <pre class="prettyprint source linenums"><code>/**
|
30 | * Copyright (c) 2013 - 2014 GE Global Research. All rights reserved.
|
31 | * The copyright to the computer software herein is the property of
|
32 | * GE Global Research. The software may be used and/or copied only
|
33 | * with the written permission of GE Global Research or in accordance
|
34 | * with the terms and conditions stipulated in the agreement/contract
|
35 | * under which the software has been supplied.
|
36 | */
|
37 |
|
38 | (function () {
|
39 |
|
40 | 'use strict';
|
41 |
|
42 | /**
|
43 | * Creates new TestHelper
|
44 | * @class TestHelper
|
45 | */
|
46 | var TestHelper = function () {
|
47 | var chai = require('chai');
|
48 | var TestHelperPO = require("./TestHelperPO.js");
|
49 |
|
50 | global.expect = chai.expect;
|
51 | global.should = chai.should();
|
52 | global.assert = chai.assert;
|
53 | chai.use(require('chai-as-promised'));
|
54 | var logger = require('./Logger.js');
|
55 | var EC = protractor.ExpectedConditions;
|
56 | var elementManager;
|
57 | var waitTime = 1000000;
|
58 | var drag = ("./drag.js");
|
59 | var dragFn = ('./dragFn.js');
|
60 |
|
61 | return {
|
62 | setWaitTime: function (wait) {
|
63 | waitTime=wait;
|
64 | console.log("Assigned wait time to: "+ wait);
|
65 | logger.info("Assigned wait time to: "+ wait)
|
66 | },
|
67 |
|
68 | /**
|
69 | * Assert if expected is included.
|
70 | * @method getRandomString
|
71 | * @returns {String}
|
72 | */
|
73 | // To generate a random String name
|
74 | getRandomString: function () {
|
75 | var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
76 | var string_length = 8;
|
77 | var randomstring = '';
|
78 | for (var i = 0; i < string_length; i++) {
|
79 | var rnum = Math.floor(Math.random() * chars.length);
|
80 | randomstring += chars.substring(rnum, rnum + 1);
|
81 | }
|
82 | logger.info("Generated random string: " + randomstring)
|
83 | return randomstring;
|
84 | },
|
85 |
|
86 | /**
|
87 | * Assert if expected is included.
|
88 | * @method assertInclude
|
89 | * @param {object} actual
|
90 | * @param {object} expected
|
91 | * @param callbackOnError
|
92 | * @returns {promise}
|
93 | */
|
94 |
|
95 | assertInclude: function (actual, expected, callbackOnError) {
|
96 | var error;
|
97 | try {
|
98 | logger.info('Asserting if actual: ' + actual + " is included in expected: " + expected + "\n");
|
99 | assert.include(actual, expected)
|
100 | } catch (e) {
|
101 | error = e;
|
102 | logger.info("Error on assertInclude: " + error);
|
103 | if (callbackOnError) {
|
104 | return callbackOnError(error)
|
105 | }
|
106 | }
|
107 | return error
|
108 | },
|
109 |
|
110 | /**
|
111 | * Assert if expected is equal to actual
|
112 | * @param actual
|
113 | * @param expected
|
114 | * @param callbackOnError
|
115 | * @returns {promise}
|
116 | */
|
117 | assertEqual: function (actual, expected, callbackOnError) {
|
118 | var error;
|
119 | try {
|
120 | logger.info('Asserting if actual: ' + actual + " is equal to expected: " + expected + "\n");
|
121 | logger.info(assert.equal(actual, expected));
|
122 | assert.equal(actual, expected);
|
123 | } catch (e) {
|
124 | error = e;
|
125 | logger.info('Error in assertEqual: ' + error + "\n");
|
126 | if (callbackOnError) {
|
127 | callbackOnError(error)
|
128 | }
|
129 | }
|
130 | return error;
|
131 |
|
132 | },
|
133 |
|
134 | /**
|
135 | * Assert if something is True
|
136 | * @param promise
|
137 | * @param callbackOnError
|
138 | * @returns {promise}
|
139 | */
|
140 | assertTrue: function (promise, callbackOnError) {
|
141 | var error;
|
142 | try {
|
143 | logger.info('Asserting if actual: ' + promise + " is equal to True \n");
|
144 | assert.isTrue(promise);
|
145 | } catch (e) {
|
146 | error = e;
|
147 | logger.info('Error in assertTrue: ' + error + "\n");
|
148 | if (callbackOnError) {
|
149 | callbackOnError(error)
|
150 | }
|
151 | }
|
152 | return error;
|
153 |
|
154 | },
|
155 | /**
|
156 | * Waits for all the angular content to load on the page
|
157 | * @method waitForAngular
|
158 | */
|
159 | waitForAngular: function () {
|
160 | try {
|
161 | browser.waitForAngular();
|
162 | } catch (e) {
|
163 | console.log("Ignoring Error ", e);
|
164 | logger.info("Ignoring Error " + e + "\n");
|
165 | }
|
166 | },
|
167 | /**
|
168 | * An expectation to check if element is present on the DOM of a page and visible. **Can also provide element directly instead of the page,element of element repo**
|
169 | * @method isElementPresent
|
170 | * @param page {String} Page of element repository
|
171 | * @param ele {string} Element name
|
172 | * @return promise
|
173 | */
|
174 |
|
175 | isElementPresent: function (page, ele) {
|
176 |
|
177 | if (typeof page == "string") {
|
178 | var locator = elementManager.findElement(page, ele)
|
179 | return browser.wait(EC.visibilityOf(locator), waitTime).then(
|
180 | function () {
|
181 | logger.info("Found " + ele + "!\n");
|
182 | return true;
|
183 | },
|
184 | function () {
|
185 | return false;
|
186 | })
|
187 | }
|
188 | else {
|
189 | return browser.wait(EC.visibilityOf(page), waitTime, "false").then(function () {
|
190 | // logger.info("Found " + ele.locator().value + "!\n");
|
191 | return true
|
192 | }, function () {
|
193 | logger.info("Did not find: " + page.locator().value + "!\n");
|
194 | return false
|
195 | })
|
196 | }
|
197 | },
|
198 |
|
199 | /**
|
200 | * An expectation to check if element is NOT present on the DOM of a page or visible. **Can also provide element directly instead of the page,element of element repo**
|
201 | * @method isElementNotPresent
|
202 | * @param page {String} Page of element repository
|
203 | * @param ele {string} Element name
|
204 | * @return promise
|
205 | */
|
206 | isElementNotPresent: function (page, ele) {
|
207 | if (typeof page == "string") {
|
208 | var locator = elementManager.findElement(page, ele)
|
209 | return browser.wait(EC.not(EC.visibilityOf(locator)), waitTime).then(
|
210 | function () {
|
211 | logger.info("Found " + ele + "!\n");
|
212 | return true;
|
213 | },
|
214 | function () {
|
215 | return false;
|
216 | })
|
217 | }
|
218 | else {
|
219 | return browser.wait(EC.not(EC.visibilityOf(page)), waitTime, "false").then(function () {
|
220 | // logger.info("Found " + ele.locator().value + "!\n");
|
221 | return true
|
222 | }, function () {
|
223 | logger.info("Did not find: " + page.locator().value + "!\n");
|
224 | return false
|
225 | })
|
226 | }
|
227 | },
|
228 |
|
229 | /**
|
230 | * An expectation to check until element disappears. **Can also provide element directly instead of the page,element of element repo**
|
231 | * @method waitForElementToDisappear
|
232 | * @param page {String} Page of element repository
|
233 | * @param ele {string} Element name
|
234 | * @return promise
|
235 | */
|
236 |
|
237 | waitForElementToDisappear: function (page, ele) {
|
238 | if (typeof page == "string") {
|
239 | var locator = elementManager.findElement(page, ele)
|
240 | return browser.wait(EC.invisibilityOf(locator), waitTime).then(function () {
|
241 | logger.info("Element " + ele + "disappeared!\n");
|
242 | return true
|
243 | },
|
244 | function () {
|
245 | return false;
|
246 | })
|
247 | }
|
248 | else {
|
249 | return browser.wait(EC.invisibilityOf(page), waitTime, "false").then(function () {
|
250 | logger.info("Element " + ele + "disappeared!\n");
|
251 | return true
|
252 | },
|
253 | function () {
|
254 | return false;
|
255 | })
|
256 | }
|
257 | },
|
258 |
|
259 | /**
|
260 | * An expectation to check if element is present on the DOM of a page and visible (same as isElementPresent
|
261 | * but returns boolean) **Can also provide element directly instead of the page,element of element repo**
|
262 | * @method isElementVisible
|
263 | * @param {String} page
|
264 | * @param {string} elementName
|
265 | * @return boolean
|
266 | */
|
267 |
|
268 | isElementVisible: function (page, ele) {
|
269 | if (typeof page == "string") {
|
270 | var locator = elementManager.findElement(page, ele)
|
271 |
|
272 | return browser.wait(locator.isPresent(), waitTime).then(function (data) {
|
273 | if (data === true) {
|
274 | logger.info("Found " + ele + "!\n");
|
275 | return browser.wait(locator.isDisplayed(), waitTime).then(function (isdisplayed) {
|
276 | if (isdisplayed) {
|
277 | logger.info("is Visible " + ele + "!\n")
|
278 | return isdisplayed
|
279 | } else {
|
280 | logger.info("not Visible " + ele + "!\n")
|
281 | return isdisplayed
|
282 | }
|
283 |
|
284 | })
|
285 | }
|
286 | else {
|
287 | logger.info("Not Found " + ele + "!\n");
|
288 | return data
|
289 | }
|
290 | })
|
291 | }
|
292 | else {
|
293 | return browser.wait(page.isPresent(), waitTime).then(function (data) {
|
294 | if (data === true) {
|
295 | logger.info("Found " + page.locator().value + "!\n");
|
296 | return browser.wait(page.isDisplayed(), waitTime).then(function (isdisplayed) {
|
297 | if (isdisplayed) {
|
298 | logger.info("is Visible " + page.locator().value + "!\n")
|
299 | return isdisplayed
|
300 | } else {
|
301 | logger.info("not Visible " + page.locator().value + "!\n")
|
302 | return isdisplayed
|
303 | }
|
304 |
|
305 | })
|
306 | }
|
307 | else {
|
308 | logger.info("Not Found " + page.locator().value + "!\n");
|
309 | return data
|
310 | }
|
311 | })
|
312 | }
|
313 | },
|
314 |
|
315 | /**
|
316 | * An Expectation for checking an element is visible and enabled such that you can click it. **Can also provide element directly instead of the page,element of element repo**
|
317 | * @method elementToBeClickable
|
318 | * @param {String} page
|
319 | * @param {string} elementName
|
320 | * @returns {promise}
|
321 | */
|
322 | /*elementToBeClickable: function (page, element) {
|
323 | var locator = elementManager.findElement(page, element);
|
324 |
|
325 | return browser.wait(function () {
|
326 | return locator.click().then(
|
327 | function () {
|
328 | logger.info("Clicked on" + element + "!\n");
|
329 | return true;
|
330 | },w
|
331 | function () {
|
332 | logger.info(element + " Not Clickable!\n");
|
333 | return false;
|
334 | });
|
335 | }, waitTime);
|
336 | },*/
|
337 |
|
338 | elementToBeClickable: function (page, ele) {
|
339 | if (typeof page == "string") {
|
340 | var locator = elementManager.findElement(page, ele);
|
341 |
|
342 | return browser.wait(function () {
|
343 | return locator.click().then(
|
344 | function () {
|
345 | logger.info("Clicked on" + ele + "!\n");
|
346 | return true;
|
347 | },
|
348 | function () {
|
349 | // logger.info(ele + " Not Clickable!\n");
|
350 | return false;
|
351 | });
|
352 | }, waitTime);
|
353 | }
|
354 | else {
|
355 | return browser.wait(function () {
|
356 | return page.click().then(function () {
|
357 | logger.info("Clicked on " + page.locator().value + "!\n");
|
358 | return true
|
359 | }, function () {
|
360 | // logger.info(ele.locator().value + " Not Clickable!\n");
|
361 | return false
|
362 | })
|
363 | }, waitTime)
|
364 | }
|
365 | },
|
366 |
|
367 | /**
|
368 | * Checks for the element to be present and then sends keys. **Can also provide element directly instead of the page,element of element repo**
|
369 | * @method sendKeys
|
370 | * @param {String} page
|
371 | * @param {String} element
|
372 | * @param {String} text
|
373 | */
|
374 | sendKeys: function (page, ele, text) {
|
375 | if (typeof page == "string") {
|
376 | return this.isElementPresent(page, ele).then(function () {
|
377 | var locator = elementManager.findElement(page, ele);
|
378 | logger.info("Sending Keys to " + ele + ": '" + text + "'")
|
379 | return locator.sendKeys(text);
|
380 | });
|
381 | }
|
382 | else {
|
383 | return this.isElementPresent(page).then(function () {
|
384 | logger.info("Sending Keys to " + page.locator().value + ": '" + ele + "'")
|
385 | return page.sendKeys(ele)
|
386 | })
|
387 | }
|
388 | },
|
389 |
|
390 | /**
|
391 | * Checks for the element to be present and then gets text. **Can also provide element directly instead of the page,element of element repo**
|
392 | * @method getText
|
393 | * @param {String} page
|
394 | * @param {String} element
|
395 | */
|
396 | getText: function (page, ele) {
|
397 | if (typeof page == "string") {
|
398 | return this.isElementPresent(page, ele).then(function () {
|
399 | var locator = elementManager.findElement(page, ele);
|
400 | return locator.getText().then(function (text) {
|
401 | logger.info("Text Value of " + ele + ": " + text)
|
402 | return text
|
403 | })
|
404 | });
|
405 | }
|
406 | else {
|
407 | return this.isElementPresent(page).then(function () {
|
408 | return page.getText().then(function (text) {
|
409 | logger.info("Text Value of " + page.locator().value + ": " + text)
|
410 | return text;
|
411 | })
|
412 | })
|
413 | }
|
414 | },
|
415 |
|
416 | /**
|
417 | * Expect an alert to be present.
|
418 | * @method alertIsPresent
|
419 | * @returns {promise}
|
420 | */
|
421 | alertsIsPresent: function () {
|
422 |
|
423 | return browser.wait(EC.alertIsPresent(), waitTime);
|
424 | },
|
425 |
|
426 | /**
|
427 | * Accepts alert dialog box
|
428 | * @method acceptAlert
|
429 | */
|
430 |
|
431 | acceptAlert: function () {
|
432 | return browser.switchTo().alert().accept();
|
433 | },
|
434 |
|
435 | /**
|
436 | * Dismisses alert dialog box
|
437 | * @method dismissAlert
|
438 | */
|
439 |
|
440 | dismissAlert: function () {
|
441 | return browser.switchTo().alert().dismiss();
|
442 | },
|
443 |
|
444 | /**
|
445 | * An expectation for checking if the given text is present in the element. **Can also provide element directly instead of the page,element of element repo**
|
446 | * @method textToBePresentInElement
|
447 | * @param {String} page
|
448 | * @param {string} elementName
|
449 | * @param {string} text
|
450 | * @returns {promise}
|
451 | */
|
452 | textToBePresentInElement: function (page, element, text) {
|
453 | if (typeof page == "string") {
|
454 | var locator = elementManager.findElement(page, element)
|
455 | return browser.wait(EC.textToBePresentInElement(locator, text), waitTime).then(
|
456 | function () {
|
457 | logger.info(text + " is present in " + element + "!\n");
|
458 | return true;
|
459 | },
|
460 | function () {
|
461 | logger.info(text + " is NOT present in " + element + "!\n");
|
462 | return false;
|
463 | });
|
464 | }
|
465 | else {
|
466 | return browser.wait(EC.textToBePresentInElement(page, element), waitTime).then(function () {
|
467 | logger.info(element + " is present in " + page.locator().value + "!\n");
|
468 | return true
|
469 | }, function () {
|
470 | logger.info(element + " is NOT present in " + page.locator().value + "!\n");
|
471 | return false
|
472 | })
|
473 | }
|
474 | },
|
475 |
|
476 | /**
|
477 | * An expectation for checking if the given text is present in the element’s value. **Can also provide element directly instead of the page,element of element repo**
|
478 | * @method textToBePresentInElementValue
|
479 | * @param {String} page
|
480 | * @param {string} elementName
|
481 | * @param {string} text
|
482 | * @returns {promise}
|
483 | */
|
484 | textToBePresentInElementValue: function (page, element, text) {
|
485 | if (typeof page == "string") {
|
486 | var locator = elementManager.findElement(page, element);
|
487 | return browser.wait(EC.textToBePresentInElementValue(locator, text), waitTime).then(
|
488 | function () {
|
489 | logger.info(text + " is present in " + element + "'s value!\n");
|
490 | return true;
|
491 | },
|
492 | function () {
|
493 | logger.info(text + " is NOT present in " + element + "'s value!\n");
|
494 | return false;
|
495 | });
|
496 | }
|
497 | else {
|
498 | return browser.wait(EC.textToBePresentInElementValue(page, element), waitTime).then(function () {
|
499 | logger.info(element + " is present in " + page.locator().value + "'s value!\n");
|
500 | return true
|
501 | }, function () {
|
502 | logger.info(element + " is NOT present in " + page.locator().value + "'s value!\n");
|
503 | return false
|
504 | })
|
505 | }
|
506 | },
|
507 |
|
508 | /**
|
509 | * Checks to see if element is selected. **Can also provide element directly instead of the page,element of element repo**
|
510 | * @method elementToBeSelected
|
511 | * @param {string} page
|
512 | * @param {string} element
|
513 | * @returns {promise}
|
514 | */
|
515 | elementToBeSelected: function (page, element) {
|
516 | if (typeof page == "string") {
|
517 | var locator = elementManager.findElement(page, element);
|
518 | return browser.wait(EC.elementToBeSelected(locator), waitTime).then(
|
519 | function () {
|
520 | logger.info(element + " is selected!\n");
|
521 | return true;
|
522 | },
|
523 | function () {
|
524 | logger.info(element + " is NOT selected!\n");
|
525 | return false;
|
526 | });
|
527 | }
|
528 | else {
|
529 | return browser.wait(EC.elementToBeSelected(page), waitTime).then(function () {
|
530 | logger.info(page.locator().value + " is selected!\n");
|
531 | return true
|
532 | }, function () {
|
533 | logger.info(page.locator().value + " is NOT selected!\n");
|
534 | return false
|
535 | })
|
536 | }
|
537 | },
|
538 |
|
539 | /**
|
540 | * An expectation for checking that the title contains a case-sensitive substring.
|
541 | * @method titleContains
|
542 | * @param {string} text
|
543 | * @returns {promise}
|
544 | */
|
545 | titleContains: function (text) {
|
546 | return browser.wait(EC.titleContains(text), waitTime);
|
547 | },
|
548 |
|
549 | /**
|
550 | * An expectation for checking the title of a page.
|
551 | * @method titleIs
|
552 | * @param {string} text
|
553 | * @returns {promise}
|
554 | */
|
555 | titleIs: function (text) {
|
556 |
|
557 | return browser.wait(EC.titleIs(text), waitTime);
|
558 | },
|
559 |
|
560 | /**
|
561 | * Sets the element manager
|
562 | * @method setElementManager
|
563 | * @param {Object} eM
|
564 | */
|
565 | setElementManager: function (eM) {
|
566 | elementManager = eM;
|
567 | },
|
568 |
|
569 | /**
|
570 | * Gets the element manager
|
571 | * @method getElementManager
|
572 | * @return {Object}
|
573 | */
|
574 | getElementManager: function () {
|
575 | return elementManager;
|
576 | },
|
577 |
|
578 | /**
|
579 | * Uploads file in upload dialog box
|
580 | * @method uploadFile
|
581 | * @param {String} filePath
|
582 | */
|
583 |
|
584 | uploadFile: function (filePath) {
|
585 | var absolutePath = path.resolve(__dirname, filePath);
|
586 | var a = $('input[type="file"]');
|
587 | fs.stat(absolutePath, function (err, stat) {
|
588 | if (err == null) {
|
589 | logger.info("File exists");
|
590 | console.log("File exists");
|
591 | a.sendKeys(absolutePath)
|
592 | logger.info("File Uploaded");
|
593 | } else if (err.code == "ENOENT") {
|
594 | logger.info("File does not exist!");
|
595 | console.error("File does not exist!")
|
596 | } else {
|
597 | logger.info("Some other error: ", err.code);
|
598 | console.log("Some other error: ", err.code);
|
599 | }
|
600 | })
|
601 | },
|
602 | /**
|
603 | * Switches to specific iFrame
|
604 | * @method iFrameSwitch
|
605 | * @param {String} page
|
606 | * @param {String} element
|
607 | */
|
608 | iFrameSwitch: function (page, element) {
|
609 | if (typeof page == "string") {
|
610 | return this.isElementPresent(page, element).then(function () {
|
611 | elementManager.browserFindElement(page, element).then(function (ele) {
|
612 | browser.switchTo().frame(ele).then(function () {
|
613 | logger.info("Switched over to " + ele + "iFrame");
|
614 | });
|
615 | })
|
616 | })
|
617 | }
|
618 | },
|
619 | /**
|
620 | * Scrolls until the element is in view. **Can also provide element directly instead of the page,element of element repo**
|
621 | * @method scrollIntoView
|
622 | * @param {String} page
|
623 | * @param {String} element
|
624 | */
|
625 | scrollIntoView: function (page, element) {
|
626 | if (typeof page == "string") {
|
627 | return this.isElementPresent(page, element).then(function () {
|
628 | var locator = elementManager.findElement(page, element);
|
629 | browser.executeScript('arguments[0].scrollIntoView()', locator.getWebElement()).then(function () {
|
630 | logger.info("Scrolled to " + element + "\n")
|
631 | })
|
632 | })
|
633 | }
|
634 | else {
|
635 | return this.isElementPresent(page).then(function () {
|
636 | browser.executeScript("arguments[0].scrollIntoView()", page.getWebElement()).then(function () {
|
637 | logger.info("Scrolled to " + page.locator().value + "\n")
|
638 | })
|
639 | })
|
640 | }
|
641 | },
|
642 |
|
643 | /**
|
644 | * Drags and drops element to specified location. **Can also provide element directly instead of the page,element of element repo**
|
645 | * @method dragAndDrop
|
646 | * @param {String} dragPage
|
647 | * @param {String} dragElement
|
648 | * @param {String} dropPage
|
649 | * @param {String} dropElement
|
650 | */
|
651 |
|
652 | dragAndDrop: function (dragPage, dragElement, dropPage, dropElement) {
|
653 | if (typeof page == "string") {
|
654 | return this.isElementPresent(dragPage, dragElement).then(function () {
|
655 | var dragLocator = elementManager.findElement(dragPage, dragElement);
|
656 | var dropLocator = elementManager.findElement(dropPage, dropElement);
|
657 | dragLocator.getAttribute("draggable").then(function (isDragable) {
|
658 | if (isDragable != null) {
|
659 | browser.executeScript(drag, dragLocator.getWebElement(), dropLocator.getWebElement()).then(function () {
|
660 | logger.info("Dragged " + dragElement + " to " + dropElement)
|
661 | })
|
662 | } else {
|
663 | browser.executeScript(dragFn, dragLocator.getWebElement(), dropLocator.getWebElement()).then(function () {
|
664 | logger.info("Dragged " + dragElement + " to " + dropElement)
|
665 | browser.actions().mouseMove(dropLocator).mouseUp().perform();
|
666 | })
|
667 | }
|
668 | })
|
669 | });
|
670 | }
|
671 | else {
|
672 | return this.isElementPresent(dragPage).then(function () {
|
673 | dragPage.getAttribute("draggable").then(function (isDragable) {
|
674 | if (isDragable != null) {
|
675 | browser.executeScript(drag, dragPage.getWebElement(), dragElement.getWebElement()).then(function () {
|
676 | logger.info("Dragged " + dragPage.locator().value + " to " + dragElement.locator().value)
|
677 | })
|
678 | } else {
|
679 | browser.executeScript(dragFn, dragPage.getWebElement(), dragElement.getWebElement()).then(function () {
|
680 | logger.info("Dragged " + dragPage.locator().value + " to " + dragElement.locator().value)
|
681 | browser.actions().mouseMove(dragElement).mouseUp().perform();
|
682 | })
|
683 | }
|
684 | })
|
685 | });
|
686 | }
|
687 | },
|
688 |
|
689 | /**
|
690 | * Drags and drops element to specified location. **Can also provide element directly instead of the page,element of element repo**
|
691 | * @method dragAndDrop2
|
692 | * @param {String} dragPage
|
693 | * @param {String} dragElement
|
694 | * @param {String} dropPage
|
695 | * @param {String} dropElement
|
696 | */
|
697 |
|
698 | dragAndDrop2: function (dragPage, dragElement, dropPage, dropElement) {
|
699 | if (typeof page == "string") {
|
700 | return this.isElementPresent(dragPage, dragElement).then(function () {
|
701 | var dragLocator = elementManager.findElement(dragPage, dragElement);
|
702 | var dropLocator = elementManager.findElement(dropPage, dropElement);
|
703 | browser.actions().dragAndDrop(dragLocator, dropLocator).mouseUp().perform()
|
704 | });
|
705 | }
|
706 | else {
|
707 | return this.isElementPresent(dragPage).then(function () {
|
708 | browser.actions().dragAndDrop(dragPage, dragElement).mouseUp().perform()
|
709 | })
|
710 | }
|
711 | },
|
712 |
|
713 | /**
|
714 | * Gets attribute value of specified element. **Can also provide element directly instead of the page,element of element repo**
|
715 | * @method getAttribute
|
716 | * @param {String} page
|
717 | * @param {String} element
|
718 | * @param {String} attribute
|
719 | */
|
720 |
|
721 | getAttribute: function (page, element, attribute) {
|
722 | if (typeof page == "string") {
|
723 | console.log("inside here 22")
|
724 | return this.isElementPresent(page, element).then(function () {
|
725 | var locator = elementManager.findElement(page, element);
|
726 | return locator.getAttribute(attribute).then(function (attributeText) {
|
727 | logger.info(element + "'s attribute " + attribute + ": " + attributeText)
|
728 | return attributeText;
|
729 | });
|
730 | });
|
731 | }
|
732 | else {
|
733 | return this.isElementPresent(page).then(function () {
|
734 | return page.getAttribute(element).then(function (attributeText) {
|
735 | logger.info(page.locator().value + "'s attribute " + element + ": " + attributeText)
|
736 | return attributeText;
|
737 | })
|
738 | });
|
739 | }
|
740 | },
|
741 |
|
742 | /**
|
743 | * Gets css value of specified element. **Can also provide element directly instead of the page,element of element repo**
|
744 | * @method getCssValue
|
745 | * @param {String} page
|
746 | * @param {String} element
|
747 | * @param {String} cssAttribute
|
748 | */
|
749 |
|
750 | getCssValue: function (page, element, cssAttribute) {
|
751 | if (typeof page == "string") {
|
752 | return this.isElementPresent(page, element).then(function () {
|
753 | var locator = elementManager.findElement(page, element);
|
754 | return locator.getCssValue(cssAttribute).then(function (cssTextValue) {
|
755 | logger.info(element + "'s CSS Value " + cssAttribute + ": " + cssTextValue)
|
756 | return cssTextValue;
|
757 | })
|
758 | });
|
759 | }
|
760 | else {
|
761 | return this.isElementPresent(page).then(function () {
|
762 | return page.getCssValue(element).then(function (cssTextValue) {
|
763 | logger.info(page.locator().value + "'s CSS Value " + element + ": " + cssTextValue)
|
764 | return cssTextValue
|
765 | })
|
766 | });
|
767 | }
|
768 | },
|
769 |
|
770 | /**
|
771 | * Logs in the GE SSO page. (Default username and password are provided) Parameters are optional
|
772 | * @method geSSOLogin
|
773 | * @param {String} username
|
774 | * @param {String} password
|
775 | */
|
776 |
|
777 | geSSOLogin: function (username, password) {
|
778 |
|
779 | var userName;
|
780 | var passWord;
|
781 |
|
782 | if (typeof username != "undefined")
|
783 | userName = username
|
784 | else
|
785 | userName = "502641091"
|
786 | if (typeof password != "undefined")
|
787 | passWord = password
|
788 | else
|
789 | passWord = "Aut0mati0n"
|
790 | return TestHelperPO.isElementPresent(element(by.id("username"))).then(function () {
|
791 | element(by.id("username")).sendKeys(userName);
|
792 | element(by.id("password")).sendKeys(passWord);
|
793 | element(by.id("password")).sendKeys(protractor.Key.ENTER);
|
794 | logger.info("Logged in GE SSO Page")
|
795 | })
|
796 | }
|
797 |
|
798 | }
|
799 | }
|
800 |
|
801 | module.exports = new TestHelper();
|
802 |
|
803 | }())
|
804 | </code></pre>
|
805 | </article>
|
806 | </section>
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | </div>
|
812 |
|
813 | <nav>
|
814 | <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>
|
815 | </nav>
|
816 |
|
817 | <br class="clear">
|
818 |
|
819 | <footer>
|
820 | 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)
|
821 | </footer>
|
822 |
|
823 | <script> prettyPrint(); </script>
|
824 | <script src="scripts/linenumber.js"> </script>
|
825 | </body>
|
826 | </html>
|