【问题标题】:GEB get background and text colorGEB 获取背景和文本颜色
【发布时间】:2014-09-25 10:24:33
【问题描述】:

我尝试了 jQuery 和 javascript 方法来获取背景或文本颜色,但我总是在下面得到一个异常。

groovy.lang.MissingMethodException: No signature of method: geb.navigator.NonEmptyNavigator.css() is applicable for argument types: (java.lang.String) values: [background-color]

代码如下

class BrandingPageSpec extends GebReportingSpec {
    def "Scenario: Selecting a pre-set colours should preview the changes."() {
        expect: "currently at the branding page"
            at BrandingPage

        and: "advance settings hide successfully"
            normalSectionHeader.css("background-color") == "#FFFFFF"

        and: "stays at branding page"
            at BrandingPage
    }
}

class BrandingPage extends Page {

    static at = {
        waitFor(wait: true) {js."document.readyState" == "complete"}
    }

    static content = {
        normalSectionHeader{$('#section-header')}
    }

    static url = "http://someDomain:8080/branding"
}
h1{
  background-color: #FFFFFF
}
<html>
  <body>
    <h1 id="section-header" > Hello Word </h1>
  </body>
</html>

任何帮助将不胜感激。谢谢

【问题讨论】:

  • 你想在 jquery 中得到 background-colorh1 对吗?

标签: jquery grails groovy geb


【解决方案1】:

替换:

normalSectionHeader.css("background-color") == "#FFFFFF"

为:

normalSectionHeader.jquery.css("background-color") == "#FFFFFF"

仅供参考:http://www.gebish.org/manual/current/javascript.html#jquery_integration

【讨论】:

  • 谢谢这个人,但它返回 rgb(##,##,##) 而不是十六进制颜色值。
【解决方案2】:

Navigator.css(String) 方法是最近添加的,目前仅在 0.9.4-SNAPSHOT 中可用。

您需要使用快照或@jripoll 建议的解决方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    • 2015-11-18
    • 1970-01-01
    • 2023-04-10
    相关资源
    最近更新 更多