我正在使用Geb和Selenium,并注意到引用某些SVG元素的测试在某些PhantomJS版本上会失败。如果我使用的是PhantomJS 1.9.1,则在Highcharts演示站点上运行的测试通过,但在1.9.7上失败- SVG tspan元素被成功定位(size() > 0通过),但text()返回空字符串。
我已经能够隔离出问题不是Geb特定的-当我直接与PhantomJSDriver交互时,我得到了同样的问题。
所以我不知道下一步该去哪里解决这个问题:是PhantomJS远程驱动程序的问题,还是PhantomJS本身的问题?我该如何解决问题所在?
import geb.spock.GebReportingSpec;
class TspanSpec extends GebReportingSpec {
def "tspan elements found but can't get text"() {
when:
go "http://www.highcharts.com/demo/bar-stacked"
then:
waitFor { $("g.highcharts-axis").find("tspan").size() > 0 }
$("g.highcharts-axis").find("tspan").text() == "Total fruit consumption"
}
}发布于 2015-05-28 22:14:31
找到了一个解决方法:使用jQuery对象而不是WebElement检索文本。
$("g.highcharts-axis").find("tspan").jquery.text() == "Total fruit consumption"https://stackoverflow.com/questions/25693949
复制相似问题