我一直在使用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发布于 2018-02-03 17:03:40
您在测试中使用的路径是什么?
我假设用于测试的图像放在主机上的desktop/testdata/中。但是测试应该在/home/seluser/data中查找它们,因为它是容器中可用的文件夹。
发布于 2018-02-03 01:29:34
在使用带有Selenium远程驱动程序的Capybara时,处理此问题的最简单方法是将图像保存在运行测试的机器上,在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的机器
https://stackoverflow.com/questions/48581306
复制相似问题