typescript - Protractor - ההמתנות על אפליקציית Angular 10 תמיד נכשלות
תודה שלקחת את השאלה שלי.
אנחנו משתמשים ב-Protractor כבר מספר שנים עם הצלחה רבה. כל האפליקציות החדשות שלנו נבנו ב-Angular 10 או שודרגו ל-Angular 10. אנחנו מסתמכים די הרבה על ההמתנות המפורשות שלנו. זה לא גרם לנו לבעיות במשך זמן רב. עם זאת, מאז השדרוג כשאנחנו משתמשים ב-waitForDisplayed או waitForClickable זה תמיד יפוג בזמן כאשר WaitForAngularEnabled=true.
מצד שני, אם WaitForAngularEnabled=false ואנחנו משתמשים ב-expectedConditions של Selenium, זה עובד בסדר. האם למישהו היו בעיות עם Angular 10 ו-Protractor?
- גרסת Node: 8.17.0
- Typescript גרסה: "^3.9.5"
- פרוטרקטור גרסה: 7.0.0
- Angular גרסה: 10.0.0
הנה שיטת ההמתנה הגנרית שלנו
import { browser, ElementFinder, ExpectedConditions as EC } from 'protractor';
/** Wait for this Component to be clickable.
* @param {number} [waitTimeoutMilliseconds] If set, override protractor defaults for maximum time to wait.
* @returns {Promise<void>} A promise that resolves when the element is clickable.
* @memberof Component
*/
public async WaitForClickable(timeoutMilliseconds?: number): Promise<void> {
try {
if(browser.waitForAngularEnabled()){
await browser.wait(EC.elementToBeClickable(this.ComponentElement), timeoutMilliseconds);
}
else{
let bEC = browser.ExpectedConditions;
return browser.wait(bEC.elementToBeClickable(this.ComponentElement), timeoutMilliseconds, "First Name text field should be visible.");
}
}
catch (e) {
throw new Error(`Component` + (this.DisplayName ? ` (${this.DisplayName}) - ` : ' - ') + `WaitForClickable:\n${e}`);
}
}
/** Waits for this Component's element to be both present on the DOM and visible.
* @param {number} [waitTimeoutMilliseconds] If set, override protractor defaults for how long to wait.
* @returns {Promise<void>} A promise that resolves when the element is present and visible.
* @memberof Component
*/
public async WaitForDisplayed(waitTimeoutMilliseconds?: number): Promise<void> {
try {
if(browser.waitForAngularEnabled()){
await browser.wait(EC.and(EC.presenceOf(this.ComponentElement), EC.visibilityOf(this.ComponentElement)), waitTimeoutMilliseconds);
}
else{
let bEC = browser.ExpectedConditions;
return browser.wait(bEC.visibilityOf(this.ComponentElement), waitTimeoutMilliseconds, "First Name text field should be visible.");
}
}
catch (e) {
throw new Error(`Component` + (this.DisplayName ? ` (${this.DisplayName}) - ` : ' - ') + `WaitForDisplayed:\n${e}`);
}
}
אנא שים לב שנאלצנו להוסיף את if(browser.waitForAngularEnabled()) כי תמיד היינו נתקעים בזמן ההמתנה ועדיין רצינו להשתמש בשיטה הכללית. הנחתי שזה בגלל שאזור האנגלר אף פעם לא מתייצב אך אני לא מצליח למצוא לכך שום סימן.
כל עזרה תוערך