【问题标题】:Get input value with Angular Harness使用 Angular Harness 获取输入值
【发布时间】:2020-05-10 17:59:20
【问题描述】:

如何使用 Angular Harness 获取 Input 的值? 我试过这个:

  readonly name = this.locatorFor('input');

  async getName(): Promise<string> {
    return (await this.name()).text();
  }

而且我总是得到空值

1) ComponentHarness should locate a required element based on CSS selector
  - Expected '' to be 'test1'.

【问题讨论】:

    标签: angular unit-testing protractor jestjs karma-jasmine


    【解决方案1】:

    所以我找到了答案, 虽然你已经输入了input.clear()之类的特定函数,但要获取你需要使用的值:

      readonly name = this.locatorFor('input');
    
      async getName(): Promise<string> {
        return (await this.name()).getProperty('value');
      }
    

    要了解有关如何使用 Angular 线束的更多信息,我建议您查看 Angular Material 的 github

    Here我找到了答案

    【讨论】:

      猜你喜欢
      • 2018-05-11
      • 2018-11-28
      • 2017-08-07
      • 2016-11-18
      • 2022-12-09
      • 2018-09-30
      • 2018-03-22
      • 1970-01-01
      • 2013-07-28
      相关资源
      最近更新 更多