我正在使用Nokogiri和Cucumber(selenium-webdriver),并且具有以下XML文件:
<root>
<records>
<record>
<rowA>www.google.com</rowA>
</record>
</records>
</root>
然后,创建以下步骤:
When /^I open my xml file$/ do
file = File.open("example.xml")
@xml = Nokogiri::XML(file)
file.close
end
Then /^I should see the url google$/ do
url = @xml.xpath('///rowA')
print(url[0].content)
@browser.get url[0].content
end
在此行中,@browser.get url[0].content
我尝试使用从XML文件捕获的URL打开浏览器,但收到错误消息:
f.QueryInterface is not a function (Selenium::WebDriver::Error::UnknownError)
有什么想法吗?
我将以这种方式编写代码:
When /^I open my xml file$/ do
@xml = Nokogiri::XML(File.read("example.xml"))
end
Then /^I should see the url google$/ do
@browser.get 'http://' + @xml.at('rowA').content
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句