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);
    }
}
                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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With