无法使用Geb在highcharts中断言轴标签文本

无法使用Geb在highcharts中断言轴标签文本,highcharts,selenium-webdriver,phantomjs,selenium-chromedriver,geb,Highcharts,Selenium Webdriver,Phantomjs,Selenium Chromedriver,Geb,我正在编写一个geb测试,它在highcharts图形中断言轴标签 我编写的测试在使用selenium chrome驱动程序运行时有效。当我使用phantomjs运行时,它失败了 //Selector in GEB $(id:"graph-id").find("g.highcharts-legend-item").find("tspan").text() 这将在Chrome中按预期返回。它在phantomjs中返回空 我们必须在CI构建中使用phantomjs。我的机器上没有phantomj

我正在编写一个geb测试,它在highcharts图形中断言轴标签

我编写的测试在使用selenium chrome驱动程序运行时有效。当我使用phantomjs运行时,它失败了

//Selector in GEB

$(id:"graph-id").find("g.highcharts-legend-item").find("tspan").text()
这将在Chrome中按预期返回。它在phantomjs中返回空


我们必须在CI构建中使用phantomjs。

我的机器上没有phantomjs,但您能否尝试一下,并更新我们的CI构建是否正常

$("#graph-id .highcharts-legend-item").find("tspan").text()

如果出于任何原因geb不正确支持您的phantomjs驱动程序,您始终可以直接通过浏览器执行javascript选择器:

def webElements = browser.driver.executeScript("""return document.querySelectorAll("#graph-id g.highcharts-legend-item tspan"); """)
def gebNavigators = webElements.collect{ new NonEmptyNavigator(browser, it) }

这将为您提供一个指向所选元素的geb导航器列表。

我们通过将phantomjs的版本从1.9.7恢复到1.9.1解决了这个问题 以及以下库依赖项:

def seleniumVersion = "2.41.0"
def gebVersion = "0.9.0"

test "org.gebish:geb-spock:$gebVersion"
test "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
test "org.seleniumhq.selenium:selenium-ie-driver:$seleniumVersion"
test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
test( "com.github.detro.ghostdriver:phantomjsdriver:1.0.4" ) {
    transitive = false
}

顺便问一下,g是什么?g是SVG中的组。相关:如果它确实正确,请不要忘记重新格式化您的答案,使其看起来像答案,而不是注释。另外,请详细说明您认为这解决了问题的原因。