【问题标题】:protractor getCssValue('background') returns several infoprotractor getCssValue('background') 返回几个信息
【发布时间】:2018-06-28 01:35:22
【问题描述】:

我有我的代码:

expect(element(by.className('nea-navbar')).getCssValue('background')).toBe('#264367');

当我运行时,期望返回:

  • Expected 'rgb(38, 67, 103) none repeat scroll 0% 0% / auto padding-box border-box' to be '#264367'.

你知道它会返回这么多信息以及如何从 rgb 传递到 hex 吗?

【问题讨论】:

    标签: jasmine protractor


    【解决方案1】:

    它传回了整个背景属性,而您只需要背景颜色:

    expect(element(by.className('nea-navbar')).getCssValue('background-color')).toBe(...);
    

    关于将 rgb 转换为 hex 的第二个问题在这里有答案: RGB to Hex and Hex to RGB

    ...这个库也声称支持: https://www.npmjs.com/package/rgb-hex

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-07
      • 2019-07-13
      相关资源
      最近更新 更多