0

I'm running my Selenium tests through Zalenium docker image. I have a test that requires a .pdf document uploading to the application. The directory I will be using to store all my .pdfs is: D:\Automation\KITS Automation\exports-endtoend-tests\Defra.Exports.EndToEnd.Tests\bin\Debug\netcoreapp2.1 I have added this path to my docker CMD window as below:

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 /d:/automation/kits automation/exports-endtoend-tests/defra.exports.endtoend.tests/bin/debug/netcoreapp2.1 --privileged dosel/zalenium start

Once added docker requests to share this file with a confirmation popup box however when I run the test I still see the error below

OpenQA.Selenium.WebDriverException : invalid argument: File not found : D:\Automation\KITS Automation\exports-endtoend-tests\Defra.Exports.EndToEnd.Tests\bin\Debug\netcoreapp2.1\test-ehc.pdf

c# Code that executes uploading the file:

        string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        string filePath = Path.Combine(folder, "test-ehc.pdf");
        driver.FindElement(By.Id("file")).SendKeys(filePath)
Steve
  • 75
  • 2
  • 13
  • If you need access to the host Docker socket, a privileged container, and arbitrary content from the host, you'll probably find it easier to run the process outside of Docker. – David Maze Nov 19 '19 at 12:25
  • Thank you David, you are right the tests run perfect locally outside of docker but it is a business requirement that the automation platform uses docker. I am sure this is possible I am just not quite there – Steve Nov 19 '19 at 12:45
  • I have also tried sharing the full D: drive via the settings in the docker application: Docker/Settings/Shared Drives after I do this I see A firewall is blocking file sharing between Windows and the containers. See documentation for more info. I have checked my firewall DockerSmbMount is enabled on both Public and Private is there anything else that is required here? – Steve Nov 19 '19 at 13:40

2 Answers2

0

This is not related to Zalenium at all. The test code, C# seems to be the case here, needs access to the file to be uploaded. Normally this is done via

driver.setFileDetector(new LocalFileDetector());

If you'd like to run the C# code inside a Docker container, please look at docker images that can be used for that. In the end, the file to be uploaded does not need to be shared with Zalenium, it needs to be shared with the container where the test code will be executed.

diemol
  • 613
  • 3
  • 10
0

This is related to Zalenium when starting Zalenium you use the command below:

docker run --rm -ti --name zalenium -p 4444:4444 -v 
/var/run/docker.sock:/var/run/docker.sock -v /D/source/repos/Defra.Git/ehco-endtoend- 
tests/src/main/resources/upload:/tmp/node/home/seluser/Downloads --privileged 
dosel/zalenium start --desiredContainers 2
Steve
  • 75
  • 2
  • 13