Tirthankar Ghosh
Tirthankar Ghosh

Reputation: 21

How to set the default download directory in Robot Framework while working in Jenkins

I have been working with Downloading of a file in the Download folder within the framework. I am using the Robot Framework and the CI tool is Jenkins.

I have configured the Base Setup Script as per this code. This works fine when I execute my scripts locally. But when its run in the Jenkins it gives me this error

WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

enter image description here

The other code is working fine when I run it in the Jenkins, but it does not set the default download directory correctly and the files are not getting downloaded to the intended directory.

Can anyone please help me in reconstructing the yellow block so that it opens the remote URL and correctly instantiates the browser and also set the desired capabilities in regards to default download location –

Upvotes: 1

Views: 3100

Answers (1)

Todor Minakov
Todor Minakov

Reputation: 20067

The first error - where the local browser is being ran on Jenkins, this one - WebDriverException: Message: 'chromedriver' executable needs to be in PATH, has nothing to do with the download directory.

It fails before that, and the message is quite informative - upon trying to start the browser, selenium tries to find its webdriver proxy - 'chromedriver' as it is Chrome, but cannot find it in the user's path.
Make sure the binary is in a directory, that's in the path.


As for your second question, what you're setting the download directory as ${EXECDIR}/Downloads. The directory you're checking for the files is ${EXECDIR}/Downloads, is on the executor node - the Jenkins, right?

Well, the case is ran off the Jenkins as executor node, but the the browser is a remote - and if it's a different node (machine) than the Jenkins one, the file is downloaded on that remote machine. So when the file is downloaded, your not checking for it in the correct node.
And also, if that node does not have the same directory as the value of ${EXECDIR}/Downloads, the download most probably failed.

Finally, you haven't called the add_experimental_options method, which is required for the setting to kick in (though you did in the first question's code) - so the download directory is the default one (even if the hub browsers is the same node as the Jenkins).

Upvotes: 1

Related Questions