1) Mastering Typescript: Embrace the Java-like syntax
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html
2) Harness the power of async and await (Protractor shifting from selenium control flow)
https://github.com/angular/protractor/tree/5.4.0/exampleTypescript/asyncAwait
// LoginPageTest.ts
describe('Protractor Typescript Test Case Example', function() {
it('Test case Name', async function (){
let loginpage:LoginPage = new LoginPage(browser);
await loginpage.enterUsername(XL);
await loginpage.isTextPresentInUsername(XL);
});
});
export class LoginPage extends Pagebase {
constructor(common){ this.driv=common; }
Username = element(by.id('userName'));
public async enterUsername(XL: Map<string, string>) {
await this.clickClearType(this.driv, this.Username, await AXL.get("userName"));
}
//Pagebase.ts
constructor(common){ this.driv=common;}
public async clickClearType(elementn, textvalue){
try {
await this.driv.wait(protractor.ExpectedConditions
.elementToBeClickable(elementn), 15000,
'Element taking too long to appear in the DOM');
// Click
await elementn.click();
// Clear
await elementn.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
await elementn.sendKeys(protractor.Key.DELETE);
// Type
await elementn.sendKeys(textvalue);
console.log("Element Clicked Successfully");
}
catch (error) {
// Handle errors here
}
}