Encountering a compile error:
error TS2339: Property 'waitForElementVisible' does not exist on type 'signinPage'
SigninPage code snippet:
export class signinPage{
constructor(){
emailInput: {
selector: 'input[type=email]';
};
passwordInput: {
selector: 'input[name=password]';
};
signinButton: {
selector: 'button[type=submit]';
};
}
signin(email, password){
return this.waitForElementVisible('@emailInput')
.setValue('@emailInput', email)
.setValue('@passwordInput', password)
.waitForElementVisible('@signinButton')
.click('@signinButton')
}
}
The issue seems to be related to the usage of 'this'. The TypeScript documentation doesn't provide clarity (https://www.typescriptlang.org/docs/home.html)
Comparing with a similar JavaScript implementation:
const signinCommands = {
signin: function(email, password) {
return this.waitForElementVisible('@emailInput')
.setValue('@emailInput', email)
.setValue('@passwordInput', password)
.waitForElementVisible('@signinButton')
.click('@signinButton');
}
};
module.exports = {
commands: [signinCommands],
elements: {
emailInput: {
selector: 'input[type=email]'
},
passwordInput: {
selector: 'input[type=password]'
},
signinButton: {
selector: 'input[type=button]'
},
}
};
An assertion in the TypeScript course that JavaScript files can seamlessly integrate is proven incorrect with this non-functional example. Misinformation abounds.