Beispiel #1
0
        private void ReturnedFileDownload(BrowserWrapper browser, string fileContent)
        {
            browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_ReturnedFile_ReturnedFileSample);
            var jsexec = browser.GetJavaScriptExecutor();

            jsexec.ExecuteScript("var downloadURL = \"\";");
            jsexec.ExecuteScript("DotVVM.prototype.performRedirect = function(url){downloadURL = url};");

            browser.First("textarea").SendKeys(fileContent);
            browser.First("input").SendKeys(Keys.Enter);
            var downloadURL = (string)jsexec.ExecuteScript("return downloadURL");

            Assert.IsNotNull(downloadURL);

            string returnedFile;

            using (var client = new WebClient())
            {
                returnedFile = client.DownloadString(browser.GetAbsoluteUrl(downloadURL));
            }
            Assert.AreEqual(fileContent, returnedFile);
        }