对Zalenium进行的Capybara测试无法找到图像

时间:2018-02-02 11:03:14

标签: capybara zalenium

我一直在努力使用Zalenium来运行我们的水豚测试。

测试运行,但我无法上传图片以测试图片上传。

我已经在Zalenium容器中安装了带有图像的文件夹,并且检查了图像是否存在,但是当使用容器中图像的文件路径时,我发现文件未找到错误。

Zalenium配置:

    docker run --rm -ti --name zalenium -p 4444:4444 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /tmp/videos:/home/seluser/videos \
  -v desktop/testdata/:/tmp/node/home/seluser/data \
  --privileged dosel/zalenium start \
  --desiredContainers 4 \
  --maxDockerSeleniumContainers 8

浏览器配置:

  when :chromeGrid
Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, :browser => :remote, url: "http://localhost:4444/wd/hub", desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome)
end

2 个答案:

答案 0 :(得分:1)

What is the path you are using in your tests?

I assume the images for the test are placed on the host machine in desktop/testdata/. But the test should look for them in /home/seluser/data, since it is the folder available in the container.

答案 1 :(得分:0)

将Capybara与Selenium远程驱动程序一起使用时,最简单的方法是让机器上的图像保持运行测试,在selenium中设置file_detector并允许它自动将图像发送到机器运行远程浏览器 - https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb#L37 - https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/remote/oss/bridge.rb#L365