0

I have been working on using Zalenium for running our capybara tests against.

The tests run, but I am unable to upload images for testing image uploads.

I have mounted the folder with the images in the Zalenium containers and I have checked that the images are there, but I get a file not found error when using the file path to the images within the containers.

Zalenium config:

    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

Browser config:

  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
  • Are you absolutely sure that Zalenium container is up an running after executing the docker run? Cause, I may be wrong, but for example, the host path for the volume supposed to be absolute. In the case you provide it's relative: "desktop/testdata/". – smileart Feb 02 '18 at 14:25
  • Thank you, my mistake, I have an absolute path in there I just shortened it for the post to remove identifying project/company names. – Captain_Test Feb 02 '18 at 15:35
  • Right. I should've guessed. Then the only suggestion I have is to mount that volume to "/home/seluser/data" instead of "/tmp/node/home/seluser/data" (what is this path, anyway?) and output the path being used on all the steps of the uploading / testing process. Especially pay attention to "/" at the beginning of the image's path. Other than that — it's almost impossible to say without seeing the code and error itself. – smileart Feb 02 '18 at 16:02

2 Answers2

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.

diemol
  • 613
  • 3
  • 10
0

When using Capybara with a Selenium remote driver, the easiest way to handle this is to keep the images on the machine running the tests, set a file_detector in selenium and allow it to automatically send the images to the machine running the remote browser - 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

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78