Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Csharp unit test for Download file dialog

I am trying to write a unit test using csharp to check if file is downloaded on click of a button. How can I find out if a download/save dialog is opened after clicking export button?

[TestMethod]
public void ExportMyFile()
{
    Home.GoToFilesPage();
    CommonFiles.ViewFile(0);
    CommonFiles.ClickExport();

    //int result = CommonFiles.ClickExport();
    //Assert.AreEqual(1, result); ???
}

public static class CommonFiles
{
    private const string ExportButton = "exportBtn";      

    public static void ClickExport()
    {
        Driver.Click(ExportButton);
    }
}
like image 566
Kurkula Avatar asked Oct 31 '22 20:10

Kurkula


2 Answers

If you are using the default save dialog from windows, you can use MS Fakes to mock that. Your mocked object will be able to tell you if it was called.

like image 119
Steve Avatar answered Nov 15 '22 05:11

Steve


I think you want to know how to confirm a file is downloaded in selenium web drive unit test.

Check out this: Access to file download dialog in Firefox

like image 33
flyfrog Avatar answered Nov 15 '22 04:11

flyfrog