问题描述
我喜欢Capybara的整体思想,但是由于某种原因我无法在Java应用程序上运行它。
I like the overall idea of Capybara, but i can't run it against the Java application for some reason.
这有可能吗?
谢谢
推荐答案
是的,有可能,我们正在做。只需将selenium-webdriver gem与firefox或Chromium一起使用,即可远程测试正在运行的应用程序。
Yes, it is possible and we are doing it. Just use the selenium-webdriver gem with firefox or Chromium to remotely test the running application.
您无法在Java测试环境中对其进行测试,因为您没有Rack基础架构,但您可以创建一个单独的ruby testsuite,并在开发计算机上运行java应用程序时运行rake(甚至可以从Rakefile自动启动该应用程序)
You can't test it from the Java test environment as you don't have the Rack infrastructure, but you can create a separate ruby testsuite and run rake when your java app is running on your development machine (or even autostart the application from the Rakefile)
这就是黄瓜的env.rb的样子:
This is how cucumber's env.rb looks like:
#
# features/support/env.rb
#
$: << File.join(File.dirname(__FILE__), "..", "..", "lib")
browser = :chrome #:htmlunit #:chrome #:firefox
host = ENV['TESTHOST'] || 'http://localhost:8080'
# may be non url was given
if not host.include?("//")
host = "https://#{host}"
end
ENV['LANG'] = "en_US.UTF-8"
require 'rubygems'
require 'capybara'
require 'capybara/cucumber'
require 'selenium-webdriver'
require 'culerity' if browser == :htmlunit
case browser
when :htmlunit
Capybara.default_driver = :culerity
Capybara.use_default_driver
else
Capybara.default_driver = :selenium
Capybara.app_host = host
end
Capybara.run_server = false
if Capybara.default_driver == :selenium
Capybara::Driver::Selenium.browser = browser
driver = Selenium::WebDriver.for browser
end
这篇关于可以用Capybara测试Java应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!