Question

So I have been working with Selenium ChromeDriver and need for my python script to find the directory where Chrome downloads to. So my script grabs a bunch of files from a site and then works with those files, but different users have set different download directories, so is there an easy way to get this information? I saw here the chromeObject class has a prefs method, but whenever I import chromedriver it doesn't include this class. Am I missing something? Do I need to import an additional module? Thanks in advance!

Was it helpful?

Solution

So there are a could approaches to this. On windows 7 at lease chrome defaults to the users download directory so something like this: C:\Users[username]\Downloads. So you could just code that paths into your test. Another option would be to create a specific test profile that specifies a specific path and you can specify it in the options to use that profile:

ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");

A third option would be to skip all the file IO stuff and use a web proxy tool to intercept the package and just deal with the data in code. This is an approach I have taken before though in c#.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top