Open ImagineImogen opened 3 years ago
after reading about the topic it is clear why this window is never present in window handles, but still not clear what to do with it. Is there a way to use Firefox profiles?
re: alert, I think it makes sense that there's no alert, because it's a download, not a javascript alert()
.
for the rest, I must admit that I don't know... maybe @ojii has an idea.
Is there a way to use Firefox profiles?
Firefox(**{"moz:firefoxOptions": {"profile": PATH_TO_PROFILE}})
https://github.com/mozilla/geckodriver/issues/1776 and https://github.com/mozilla/geckodriver/issues/1707 have snippets to configure Firefox to download files automatically without a popup.
Looks like the implied advice is still the same†, to configure the browser not to show a dialog when downloading files.
† stackoverflow advice from 2009 https://stackoverflow.com/a/1176389/705086
@ojii unfortunately, passing the profile doesn't work, it either doesn't do anything like here #30 (for me it throws an error arsenic.errors.SessionStartError: unknown error: Invalid byte 58, offset 1.
) or opens the index of the profile folder in the browser (if I use browsers.Firefox(**{'moz:firefoxOptions': {'args': ["profile", r"C:\Users\Path\to\Profile]}})
)
@dimaqq thanks for the links, I configured my Firefox to start downloading without pop-up. It is also working when I pass this configured profile to Selenium. I just cannot get it to work with Arsenic. Here it was also not possible to use Firefox capabilities #61
@ojii unfortunately, passing the profile doesn't work, it either doesn't do anything like here #30 (for me it throws an error
arsenic.errors.SessionStartError: unknown error: Invalid byte 58, offset 1.
) or opens the index of the profile folder in the browser (if I usebrowsers.Firefox(**{'moz:firefoxOptions': {'args': ["profile", r"C:\Users\Path\to\Profile]}})
)
It should be browsers.Firefox(**{'moz:firefoxOptions': {"profile": r"C:\Users\Path\to\Profile"}})
@ojii I tried that back then, and it gave me TypeError: Object of type set is not JSON serializable
. The correct way to start it is browsers.Firefox(**{'moz:firefoxOptions': {'args': ["-profile", r"C:\Users\Path\to\Profile]}})
, then I see in the logs that the driver has started with this profile (instead of a newly created one). But it doesn't do anything, just like what is mentioned here #30 . I checked how it is done in Selenium, and they are cloning the passed profile directory in the one created by webdriver. Unfortunately, Firefox profiles don't work for Arsenic yet.
Looks like a silly typo, which would explain the "set" type in the error:
- "profile", r"C:...
+ "profile": r"C:...
No, the string @ojii provided is not working, giving either arsenic.errors.SessionStartError: unknown error: Invalid byte 58, offset 1
or TypeError: Object of type set is not JSON serializable
browsers.Firefox(**{'moz:firefoxOptions': {'args': ["-profile", r"C:\Users\Path\to\Profile]}})
is working, but it is starting the webdriver with the profile provided, but it doesn't do anything, it cannot perform the GET request. Another user had the same issue #30
I believe your analysis is correct, a duplicate of #30, where PR would be very welcome 🙏
I'm trying to download files with Arsenic and I don't know how to manage the Firefox pop-up window
await session.get_alert_text()
gives meNoSuchAlert
error,await session.get_window_handles
returns only the active window and no pop-up. What's the best way to deal with it?