使用Nokogiri从XML文件捕获的打开URL

玛丽亚(Maria P.)

我正在使用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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章