Unable to assert axis label text in highcharts using Geb

╄→гoц情女王★ 提交于 2019-12-12 04:53:58

问题


I am writing a geb test that asserts the axis labels in a highcharts graph.

The test I wrote works when run with the selenium chrome driver. When I run with phantomjs it fails.

//Selector in GEB

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

This returns as expected in Chrome. It returns empty in phantomjs.

We have to use phantomjs for our CI builds.


回答1:


If for whatever reason geb isn't supporting your phantomjs driver properly, you can always execute a javascript selector directly through the browser:

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

Which will give you a list of geb navigators which point to the selected elements.




回答2:


I don't have phantomjs on my machine but can you please try this and update us whether it's working or not?

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



回答3:


We resolved the issue by reverting the version of phantomjs from 1.9.7 to 1.9.1 and the following library dependencies:

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
}


来源:https://stackoverflow.com/questions/25668423/unable-to-assert-axis-label-text-in-highcharts-using-geb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!