yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * @file Panel component base class
 * @description Allow to call switchTo function to perform clickTab action in panel (tab type) and wait for all child component presented
 * @author      Adrian Foo (adrian.foo@3ds.com), Wong Jia Hui (jiahui.wong@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { Panel } from '../e2elib/lib/src/pageobjects/panel.component';
import { QObject } from '../e2elib/lib/src/pageobjects/base/qobject.class';
 
export class PanelBase extends Panel {
  public constructor(panelComponentPath: string) {
    super(panelComponentPath);
  }
 
  /**
   * Switch to the tab and wait until all component in tab is present
   */
  public async switchTo(): Promise<void> {
    await this.clickTab();
    // Get all property name and check whether it is QObject type
    const allPropertyName = Object.getOwnPropertyNames(this);
    for (const propertyName of allPropertyName) {
      const property = Object.getOwnPropertyDescriptor(this, propertyName);
      // Call waitUntilPresent() if the property is QObject type
      if (property!.value instanceof QObject) {
        const childComponent = property!.value;
        await childComponent.waitUntilPresent();
      }
    }
  }
}