Save as (windows file dialogue) clickable by SE nodes?

Hi KNIMErs,

do the Selenium Nodes allow me to respond to a Windows “popup” message (e. g. when I click a download button on a webpage) which asks me to select a place on my local machine to save a file?

I thought of eventually adjusting the bundled Chromium browser to automatically download without asking for a location, which is a standard setting in most Chromium browsers.

Thank you in advance!

Phil

2 Likes

Hey Phil,

this is somewhat a classic – you’re by far not the first one to ask, and I always wanted to create some examples for that, so thanks for the nudge. I’ll come up with something, just a little patience! :slight_smile:

–Philipp

3 Likes

Thank you for the lightning fast response, Philipp…

I was thinking about tweaking the browser to auto download and was under the impression that SE Nodes comes with its own browser but it looks like it’s using my local version. Is that right?

My idea was to go into the browser settings and - to avoid the download dialogue - set up the (bundled?) browser so that it automatically downloads to e. g. the local Downloads folder. Is that possible?

Because if I do this for my system wide Chrome browser - the one I use all day - then I don’t want to use this setting, only when it is utilized by KNIME / SE Nodes. Is there a way to eventually run the SE Nodes with their “own” instance of the browser?

THX
Phil

Hi Phil,

let me answer these straight-away. I’ll still come up with the promised example later/tomorrow :sweat_smile:

Generally: It’s a so-so™

  1. When you select e.g. Chrome (or Firefox, …) in the settings (either in Start WebDriver or in the WebDriver Factory), Selenium will start the system installation of Chrome (the one in e.g. /Applications or /Program Files, depending on your OS). However, it will not use the same settings (aka. preferences, aka. “profile”) which your system browser uses when you launch it. Instead, Selenium will create a new, blank profile, which is per default discarded when the browser is closed. This has advantages (clean, anonymous browsing session not leaking any private data) and disadvantages (you explicitly need to log in into each website, even though you might have saved the credentials in your system browser).

  2. When you select Chromium (bundled), a browser version which is distributed with the Selenium Nodes is used. Why would and should you use this? This way, you always have a browser version which is compatible to your Selenium Nodes version. With system versions, this is typically not the case – if the version on your system is too old or new, you might see errors. We keep the Selenium Nodes always up-to-date to be compatible with the most recent browser versions, but sometimes there might be a little delay and using Chromium (bundled) will avoid any issues. Also, this is a convenient way if you run the Selenium Nodes with a KNIME Server (or similar) on which you do not have a system browser installed.

That’s generally a good idea – however it’ll not work out of the box, because of the “clean profile”.

You can share your personal browser profile with Selenium, but I generally would not recommend it (see above).

Instead, to cut this short: Have a look at the following snippet template (available both in Start WebDriver or in the WebDriver Factory):

(select the highlighted entry from the drop down menu and click “Merge” – terrible UX, sorry). This will populate the “Capabilities” section with some cryptic configuration which will look like so:

Edit the default_directory to a local path on your system. Then start the browser and when you initiate a file download (a) no system dialog should appear and (b) the file should automatically end up in the specified directory.

Actually, I think that’s almost it. So anything left for me would be to build a nice, commented example workflow and put this on my NodePit Space – tomorrow! :slight_smile:

4 Likes

Is the

/path/to/directory

KNIME local or is that a standard Windows path?

It should be a system-wide path to a directory which already exists. E.g. on Windows something like C:\Users\kowisoft\Downloads, etc.

2 Likes

Actually, I still owe you this. So, here we go:

This is admittedly a little over-engineered, but I wanted to provide some best-practice:

  1. I build the capabilities JSON dynamically to use a system-specific temp path for the download directory (i.e. avoid having something like C:\Users\Bob)

  2. It contains some logic which checks if the download is still ongoing and waits until it has finished.

Admittedly, so far only tried on a Mac. If you encounter any issues, let me know!

–Philipp

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.