Is it possible to loop through and send values to sendKeys(value)
?
I have tried various options to solve this problem but with no success.
Numbers.ts
export const Numbers = {
1: '777',
2: '777',
3: '777'
};
Texts.ts
export const Texts = {
1: '111',
2: '222',
3: '333'
};
Code.ts
public async readFromFile(): Promise<void> {
const numbers: object = Numbers;
const texts: object = Texts;
function* generatorNumbersAndTexts(objectNumbers, objectTexts) {
let i: string;
let j: string;
for (i in objectNumbers) {
for (j in objectTexts) {
if (objectNumbers.hasOwnProperty(i) && objectTexts.hasOwnProperty(j)) {
yield i;
yield j;
}
}
}
}
for (let indexI of generatorNumbersAndTexts(numbers, texts)) {
for (let indexJ of generatorNumbersAndTexts(numbers, texts)) {
texts.hasOwnProperty(indexJ)) {
await this.clickSendMessage();
try {
await this.typeContacts(numbers[indexI]);
} catch (e) {
throw new Error(`There is no phone field ${e}`);
}
await this.typeMessage(texts[indexJ]);
await this.sendMessage();
}
}
}
Methods
The following methods were utilized within the readFromFile method.
public async typeContacts(numbers: string): Promise<void> {
await this.contactField.sendKeys(numbers + ';');
}
public async typeMessage(text: string): Promise<void> {
await this.messageField.type(text);
}
public async type(text: string): Promise<void> {
await this.clearInput();
await this.sendKeys(text);
}
It appears that there may be an issue related to Protractor promises.