I'm using WebStorm with compiler target is ES6 so i don't recognize this error.
However, when i integrate with jenkin, the issue happens. Because when i set target is ES6, some issue happens and grunt ts cannot compile code to ES6. Perhaps, it does not fully support.
That's why i set target is ES5. However, with target is ES5 i got this error in runtime. I also change WebStorm with compiler target is ES5, and i also get this issue
Jenkin with grunt-ts
/**.
*/
import {BaseFragment} from 'protractor-element-extend'
import {browser, ExpectedConditions as EC, $, $$, element, by, ElementFinder} from 'protractor'
import {Locator} from "protractor/built/locators";
class TextboxClass extends BaseFragment {
constructor(element) {
super(element) //that's it! now your 'this' reference, is reference to element passed to super constructor
}//-
//You can extend it with any methods that you what, and use internal reference to your element
setContent(textSet) {
let self = this;
this.clear()
.then(function () {
return self.sendKeys(textSet);
})
.then(function () {
return self.getAttribute('value');
})
.then(function (textGet) {
if (textGet == textSet) {
console.log("Set Text '" + textGet + "' Successfully !");
return true;
}
else {
console.warn("Set Text '" + textGet + "' Unsuccessfully !");
return false;
}
})
}
getContent() {
let self = this;
self.getAttribute('value')
.then(function (textGet) {
return textGet;
})
}
}
class CheckboxClass extends BaseFragment {
constructor(element) {
super(element) //that's it! now your 'this' reference, is reference to element passed to super constructor
}
//You can extend it with any methods that you what, and use internal reference to your element
select() {
this.isSelected().then(selected => {
if (!selected) {
this.click()
// Notice that because your element is valid ElementFinder - you can pass it as parameter to ExpectedConditions!
browser.wait(EC.elementToBeSelected(this), 5000, `Checkbox ${this.locator()} must became selected after click, but it wasn't`)
} else {
console.warn(`Checkbox ${this.locator()} was already selected, skipping select`)
}
})
}
unselect() {
this.isSelected().then(selected => {
if (selected) {
this.click()
// Notice that because your element is valid ElementFinder - you can pass it as parameter to ExpectedConditions!
browser.wait(EC.not(EC.elementToBeSelected(this)), 5000, `Checkbox ${this.locator()} must became unselected after click, but it wasn't`)
} else {
console.warn(`Checkbox ${this.locator()} was already unselected, skipping unselect`)
}
})
}
}
class ComboboxClass extends BaseFragment {
constructor(element) {
super(element) //that's it! now your 'this' reference, is reference to element passed to super constructor
}
selectDropdownByIndex(index, milliseconds) {
this.findElements(by.tagName('option'))
.then(function (options) {
options[index].click();
});
if (typeof milliseconds !== 'undefined') {
browser.sleep(milliseconds);
}
}
selectRandom() {
this.element(by.xpath('//option[3]')).click();
// .then(function (options) {
// let random = Math.floor((Math.random() * (options.length - 1)));
// if (random == -1) {
// random = 0
// }
// console.log(options.length);
// if (options.length > 0) {
// options[random].click();
// }
// });
}
selectDropdownByText(Text, milliseconds) {
this.findElements(by.tagName('option'))
.then(function (options) {
for (let i = 0; i < options.length; i++) {
if (options[i].getText()
.then(function (textGet) {
if (textGet == Text) {
return true;
}
else {
return false;
}
})) {
options[i].click();
}
}
});
if (typeof milliseconds !== 'undefined') {
browser.sleep(milliseconds);
}
}
}
//Export part
export function textBox(locator, elementFlag = false) {
if (elementFlag != false) {
return new TextboxClass(locator);
}
else {
return new TextboxClass(element(locator));
}
}
export function checkBox(locator, elementFlag = false) {
if (elementFlag != false) {
return new CheckboxClass(locator);
}
else {
return new CheckboxClass(element(locator));
}
}
export function comboBox(locator, elementFlag = true) {
if (elementFlag != false) {
return new ComboboxClass(locator);
}
else {
return new ComboboxClass(element(locator));
}
}