无法使用Geb在高图中断言轴标签文本 [英] Unable to assert axis label text in highcharts using Geb

查看:154
本文介绍了无法使用Geb在高图中断言轴标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用selenium chrome驱动程序运行时所写的测试工作正常。

  // GEB中的选择器

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

这会在Chrome中按预期返回。它在phantomjs中返回空。



我们必须为我们的CI构建使用phantomjs。

解决方案<如果由于某种原因,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导航器列表指向选定的元素。


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.

解决方案

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.

这篇关于无法使用Geb在高图中断言轴标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆