SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.84k stars 768 forks source link

Selenium IDE freezes after a file download is executed #898

Open LucaAlimandi opened 4 years ago

LucaAlimandi commented 4 years ago

Running the following script, which simply executes two downloads in sequence, Selenium IDE "freezes" after performing the first download. It seems that the problem arises when the browser (Chrome) shows the list of the last downloaded files in the lower part of the window. The same happens with Firefox, even if the behaviour is different, in that it asks the user to select the folder to save the file in.

The script I use to simulate the problem is very simple: it downloads a file, waits 10 seconds until download ends, then tries to download the same file again, but at this point it freezes and doesn't go further any more... The same happens trying to download a different file or waiting a longer pause or excluding it.

I attach a screenshot of the Selenium window and the script itself.

Please let me know if a solution can be found.

LA

2019-12-02_111901

Load7ZipTest.zip

LucaAlimandi commented 4 years ago

I noticed that after the first download, Selenium IDE executes other commands that do not refer to the page itself, but freezes the first time it tries to access some page element. I think it is related to the way the browser shows the list of downloaded files, or to the fact that another page or frame is activated...

tourdedave commented 4 years ago

You provided exported Java code. Please provide a SIDE project file instead.

LucaAlimandi commented 4 years ago

Ok. I send a simple SIDE file that reproduces the test that I described earlier and a snapshot (by means of a zipped file). As you can see by the snapshot, the test freezes after the first download, even adding a pause of 10 second, much more then the time needed to execute the download. The freeze happens even if I remove the pause. Download Bug Test Side File and Snapshot.zip

capoerafreak commented 4 years ago

As far as i know, you can not download a file with Selenium IDE, because Selenium can not interact with „Chrome system pages“ like the save as dialog or the setting page

LucaAlimandi commented 4 years ago

Yes, but I (well, Selenium IDE, to be precise...) simply press a button on a page, which actually executes the download, and it works as expected; but the problem is that, after the FIRST download completes the test freezes, in the sense that any other command (like pressing a button or searching for any element on the page) does not work any more, as if the page is no more "seen" by Selenium...

LucaAlimandi commented 4 years ago

By the way, I temporarily solved my problem with a simple workaround: after the file has been downloaded, I re-open the page before clicking again the download button, as this command is ALWAYS executed, even if the browser is closed...

LucaAlimandi commented 4 years ago

Here is the modified SIDE file. As I used Chrome, I had to confirm (once for all) the permission to download miltiple files. After this, every time Selenium clicks the download button, the file is correctly downloaded, as can be seen opening the Download folder. Download Bug Test - Workaround.zip

pszewczykpl commented 4 years ago

Yes, I had the same problem. Selenium IDE clicks a button (download file), then freezes.

I write in JavaScript this and paste to Run Script function in Selenium IDE:

function wait(ms) {
    var start = new Date().getTime();
    var end = start;
    while(end < start + ms) {
        end = new Date().getTime();
    }
}
document.getElementById("s2").click();
wait(5000);
document.getElementById("finish").click();

s2 is the button that downloads the file, wait 5s and click finish after download a file. With JavaScript works good, but this same actions in Selenium IDE functions (click s2, pause 5s, click finish) not working (freezes after click s2).

But it's works only in Chrome, but Firefox not.

corevo commented 4 years ago

@pszewczykpl I would recommend you try to find a different workaround, try the repro that @LucaAlimandi posted.

Firstly this JS wait function will completely freeze the AUT, since the main thread is completely blocked, and it may not work for all apps since you've called the click function of an element rather than clicking it using Selenium IDE.

I'm glad it works for you, but this is the exception rather than the rule.

LucaAlimandi commented 4 years ago

In my case I solved re-opening the previous page with the “Open” command, like this:

It is just a workaround but it works for me!

Anyway I hope the problem will be solved sooner or later! 😊

Luca

Da: Tomer Steinfeld notifications@github.com Inviato: lunedì 2 marzo 2020 13:08 A: SeleniumHQ/selenium-ide selenium-ide@noreply.github.com Cc: LucaAlimandi l.alimandi@reply.it; Mention mention@noreply.github.com Oggetto: Re: [SeleniumHQ/selenium-ide] Selenium IDE freezes after a file download is executed (#898)

@pszewczykplhttps://github.com/pszewczykpl I would recommend you try to find a different workaround, try the repro that @LucaAlimandihttps://github.com/LucaAlimandi posted.

Firstly this JS wait function will completely freeze the AUT, since the main thread is completely blocked, and it may not work for all apps since you've called the click function of an element rather than clicking it using Selenium IDE.

I'm glad it works for you, but this is the exception rather than the rule.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SeleniumHQ/selenium-ide/issues/898?email_source=notifications&email_token=ANPZ5NAPFVLOQBZ62T3REWTRFOOTJA5CNFSM4JTT4YZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENPCA3A#issuecomment-593371244, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANPZ5NAKJPTWJHFPU6W4QETRFOOTJANCNFSM4JTT4YZA.


-- The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

pszewczykpl commented 4 years ago

In my case, I need to download the file and move to a next page staying on the same tab/window (App needed this). So, Im waiting 😃

It would be so great if Selenium IDE supported download dialog boxes (and maybe browser settings 😃 ).

MonikaBarget commented 4 years ago

I am having the same issue using Python and Firefox. Forums I checked recommended all kinds of exception handling, but the only thing that fixed it was deleting all the cookies:

try:
    driver.get(download)
    driver.back()
except:
    driver.delete_all_cookies()
    print("Failed")
    continue

My script is iterating through various URLs of a library catalogue to download .ris files. I am using a special "tech" profile on Firefox that permits different downloads just by clicking the download links, so that works great. But as for the post-download SELENIUM freeze, I had tried anything from refreshing the browser to going back. The snippet above solved the problem -- BUT the script is now terribly slow. I am not sure I have the patience to wait for my 4000 items to be downloaded. :-(

I might try Google Chrome instead of Firefox. As for Microsoft Edge, that totally sucks. Wouldn't recommend using it with selenium.

sthonnard commented 4 years ago

Hello!

I am having the same issue using R with package RSelenium on RStudio/macOS.

The workaround which worked for me is to inject a javascript on the page for forcing the refresh, before downloading the file. For instance:

inject <- function()
{
  rd$executeScript('
  setTimeout(function(){
     window.location.reload(1);
  }, 10000);')

}
download_csv <- function(url)
{
  inject()
  rd$navigate(url)
}

rd$navigate("https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html")

download_csv("https://people.sc.fsu.edu/~jburkardt/data/csv/hw_200.csv")
download_csv("https://people.sc.fsu.edu/~jburkardt/data/csv/cities.csv")
download_csv("https://people.sc.fsu.edu/~jburkardt/data/csv/hurricanes.csv")
MonikaBarget commented 4 years ago

Just to add that Google Chrome has worked just fine. I highly recommend using Chrome instead of Firefox for this specific operation. No workarounds needed.

whyameye commented 4 years ago

@MonikaBarget we use Google Chrome and have this issue. We first noticed the bug on MacOS but have confirmed the problem exists on Linux and Chrome OS as well. We have not tested Windows. Our workaround is to have the next command after the download open the same or another web page.

MonikaBarget commented 4 years ago

I used Google Chrome on Windows and had no issues at all.

easvend commented 4 years ago

Can confirm that I am also experiencing this issue when using Selenium IDE with Chrome. I used the workaround shown by @LucaAlimandi, and this solves part of the issue. We would like to extend test to look at what is displayed after the download is initiated. Navigating using the open () command does not work in such cases.

L1F13BSCS0156 commented 3 years ago

I have the same issue. i am using windows 10 with google chrome. after clicking a download button, the file downloads but Selenium IDE gets stuck and do not perform next actions.

etrajano commented 2 years ago

You provided exported Java code. Please provide a SIDE project file instead.

I was trying to use Selenium IDE to download several files and had the same issue.

Here follows a SIDE file, as requested. I've tested with Firefox (v. 100.0 (64-bits)) and Google Chrome (V. 101.0.4951.64 (Official Build) (x86_64)) on a Mac (OS X 10.13.6 (17G9016)) and the problem still persists.

freeze_reproducible.side.zip

Benczyk commented 10 months ago

@sthonnard 's workaround worked perfectly for me

Python code:

driver.execute_script('setTimeout(function(){window.location.reload(1);}, 10000);')
driver.get(url)
toddtarsi commented 10 months ago

@Benczyk - Are you experiencing this issue in v3 or v4 of selenium ide? I would be happy to try and figure out a fix in v4 if so

Benczyk commented 10 months ago

@toddtarsi That'd be nice if a future version can have this issue fixed 🍀

Before this workaround, I've tested all the options() I could find people mentioning on Stackoverflow & co, but without success.

FYI: once the workaround was in place, I was able to run a download test with 50+ files successfully.

toddtarsi commented 10 months ago

Sounds good: one more question. Is this a Selenium IDE thing (is there something wrong with python code-export for example) or is this an issue with python bindings for Selenium itself.