github.com/argoproj/argo-cd/v2@v2.10.9/ui-test/src/navigation.ts (about)

     1  import {By, WebDriver} from 'selenium-webdriver';
     2  import {ApplicationsList} from './applications-list/applications-list';
     3  import UiTestUtilities from './UiTestUtilities';
     4  import {Base} from './base';
     5  
     6  const NAVBAR_APPLICATIONS_BUTTON: By = By.css('#app .nav-bar .argo-icon-application');
     7  const NAVBAR_SETTINGS_BUTTON: By = By.css('#app .nav-bar .argo-icon-settings');
     8  const NAVBAR_USER_INFO_BUTTON: By = By.css('#app .nav-bar .fa-user-circle');
     9  const NAVBAR_DOCS_BUTTON: By = By.css('#app .nav-bar .argo-icon-docs');
    10  
    11  export class Navigation extends Base {
    12      private applicationsList: ApplicationsList;
    13  
    14      public constructor(driver: WebDriver) {
    15          super(driver);
    16          this.applicationsList = new ApplicationsList(this.driver);
    17      }
    18  
    19      /**
    20       * Click the Applications Nav Bar Button
    21       * Return: reference to ApplicationsList page
    22       */
    23      public async clickApplicationsNavBarButton(): Promise<ApplicationsList> {
    24          try {
    25              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_APPLICATIONS_BUTTON);
    26              await navBarButton.click();
    27          } catch (err) {
    28              throw new Error(err);
    29          }
    30          return this.applicationsList;
    31      }
    32  
    33      /**
    34       * Click the Settings Nav Bar Button
    35       * TODO return settings page
    36       */
    37      public async clickSettingsNavBarButton() {
    38          try {
    39              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_SETTINGS_BUTTON);
    40              await navBarButton.click();
    41          } catch (err) {
    42              throw new Error(err);
    43          }
    44      }
    45  
    46      /**
    47       * Click the User Info Nav Bar Button
    48       * TODO return User Info page
    49       */
    50      public async clickUserInfoNavBarButton() {
    51          try {
    52              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_USER_INFO_BUTTON);
    53              await navBarButton.click();
    54          } catch (err) {
    55              throw new Error(err);
    56          }
    57      }
    58  
    59      /**
    60       * Click the Documentation Nav Bar Button
    61       * TODO return docs page
    62       */
    63      public async clickDocsNavBarButton() {
    64          try {
    65              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_DOCS_BUTTON);
    66              await navBarButton.click();
    67          } catch (err) {
    68              throw new Error(err);
    69          }
    70      }
    71  
    72      /**
    73       * Get the WebDriver. Test cases are not recommended to use this. Use Page/Component objects to perform actions
    74       */
    75      public getDriver(): WebDriver {
    76          return this.driver;
    77      }
    78  
    79      /**
    80       * Call when test case is finished
    81       */
    82      public async quit() {
    83          await this.driver.quit();
    84      }
    85  
    86      /**
    87       * Sleep for t milliseconds. This is not recommended for use by test cases.
    88       * @param t
    89       */
    90      public async sleep(t: number) {
    91          await this.driver.sleep(t);
    92      }
    93  }