I have an ASP.NET WebForm.
When users click on a link, it calls another page. That page, in turn, references an assembly and initiates a download, which takes some time to appear as it is rendered on the fly.
The issue:
I want to display a popup message: "Please wait download initiated" when users click the download button. When the Internet Explorer download window appears, I want to disable the original popup.
AFAIK, Elad is true. But you can try one thing. If your are throwing content from page, then just before writing content do the stuffs you want
Related
I have a custom Dialog with 4 linked screens(which come one by one on click of a Continue button) in my ASP.Net MVC application. On the 2nd screen, the user has an option to click a button which re-directs him to a entirely different screen(but inside the Dialog). Here there is a Save button. I want the user to go back to the 2nd screen when the Save is done but the Dialog is getting closed(redirecting to the landing page from where the Dialog was thrown initially. I'm doing a return Redirect(Request.UrlReferrer.ToString()); on click of the Save button but it clearly doesn't work the way I want it to.
How can I make the user stay on the Dialog? Can you please help me with the fix?
I have 3 user controls (download page, download status page, download status). I want to make when I click the download button at the download page it has to add download status to downloadstatuspage. I couldn't make this happen. It doesn't add.
//when clicked in download page
downloadstatuspage.flowlayoutpanel.Controls.Add(downloadstatus);
NOTE: it can add a user control to itself(user control), but it cant add to another user control.
I tried everything I see on the internet but none of them worked.
So, I have an a application that needs a report to be exported in PDF. And on button click the generated pdf should open in a new tab for the user to view the contents before downloading.
My problem is opening the page in a new tab gets a pop-up blocker warning, I already tried the following:
string url = "/Page2.aspx?id="+id+;
Response.Write("<script>");
Response.Write("window.open('"+url+"','_newtab')");
Response.Write("</script>");
.......
Page.ClientScript.RegisterStartupScript(this.GetType(),"OpenWindow","window.open('"+url+"','_newtab');",true);
...
ScriptManager.RegisterStartupScript(this, this.GetType(), "NewTab", "window.open('" +url+ "');", true);
and still no progress. The redirecting should be done in the server side since I've got to get some data and passed it together with the link.
Usually a browser will block a popup unless the popup is initiated by the user.
If a window opens directly as a result of an onclick it will generally open okay. If the button click indirectly opens the window, it is more likely to be blocked. So your injecting a script tag etc. is likely to be blocked as a webpage being spammy (no-one wants unsolicited popups to appear when they browse).
Putting the window.open directly into the onclick event is the most likely solution to work.
Ultimately however you cannot control the behaviour of the browser though so it may not be possible to do what you want.
Changing the button into a styled hyperlink would work (with a target of _blank or similar). It is not possible to tell a browser to open in a new tab vs a new window.
Issue: My selenium script is not recognizing and closing a dialog box that pops up when I redirect to a URl that contains file to download. The attached image shows the dialog I am referring to.
I know this has been asked a million times and I have spent at least 24 hours researching and trying other suggestions posted across the web but with no success. I am hoping the attached image will clarify which Firefox dialog box I am referring too.
I have tried the following solutions
1. Creating IAlerts (Alert element is not found)
2. Searching by trying to find the element by xpath (xpath to cancel was not found)
3. WindowsHandler Method (was not able to figure out the window name)
Any help on this would be greatly appreciated. Thank You in advance!
FireFox Dialog
There are several types of "popups".
Javascript dialogs - These are NOT HTML dialogs but are instead Javascript created dialogs. These consist of alert(), confirm(), and prompt() and can be handled with Alert.
HTML dialogs - These take on various forms depending on how they are formatted. If you right-click on the dialog and see the typical context menu for your browser, then it's an HTML dialog. They are part of the DOM of the current page so you can use Selenium to access this just as you would any other page (e.g., no window handles needed).
Browser window - These are actually another browser window that pops up and may look like a dialog, depending on how it's formatted. It's different than an HTML dialog because it can be moved outside of the current browser page frame. You will need to use window handles to access these windows as you would another tab in the browser. Once you get ahold of the window handle, you can access the HTML of the page like any other page.
Browser dialog - these take on various forms but are akin to System dialogs. They are not made up of HTML so they cannot be accessed by Selenium. Other than using a library to access them, you can interact with them in a limited fashion by sending keys such as <SPACE>, <TAB>, <ENTER>, etc.
What you have pictured is a (4) browser dialog. They it takes on different forms depending on the browser you do the action on. Your best course of action is probably send keys. Sometimes, depending on the browser, you can specify settings to autodownload a file to a specific location so that the dialog doesn't come up. I've never used this so I can't direct you there.
I was able to find and close a download dialog box by checking the amount of open windows after the dialog appears. This solution worked for me.
Find a link to open a dialog and click it:
var link = MyBrowser.Driver.FindElement(OpenQA.Selenium.By.Id("Button"));
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click();", link);
Get the new window count after the dialog opens:
var newWindowCount = MyBrowser.Driver.WindowHandles.Count;
Switch to the newly opened dialog and close it:
MyBrowser.Driver.SwitchTo().Window(MyBrowser.Driver.WindowHandles[newWindowCount-1]);
MyBrowser.Driver.Close();
The message reads:
To help protect your security, Windows Internet Explorer blocked this site from
downloading files to your computer. Click here for more options...
I am receiving this error when I try to initiate a download after successfully filling a CAPTCHA in my ASP.NET (C#) website.
Has anybody faced this issue earlier? If so can you please let me know how you have tried to make it work. I have no option to remove the AJAX calls in my code.
This issue seems to be specific to IE7. The work around suggested for this issue by Microsoft is:
To ensure that your Web site downloads are not blocked, do not automatically launch a file download. Instead, use hyperlinks or buttons that require a user action. If you use a script to navigate to the resource, it must run synchronously within the context of the OnClick event handler for the link.
I even tried to create a button dynamically and trigger a click after my AJAX call is completed. Even then the issue is not resolved.
Try this
To stop the information bar from blocking file and software downloads
Open Internet Explorer by clicking the Start button , and then clicking Internet Explorer.
Click the Tools button, and then click Internet Options.
Click the Security tab, and then click Custom level.
Do one or both of the following:
To turn off the Information bar for ActiveX controls, scroll to the ActiveX controls and plug-ins section of the list, and then, under Automatic prompting for ActiveX controls, click Enable.
To turn off the Information bar for file downloads, scroll to the Downloads section of the list, and then, under Automatic prompting for file downloads, click Enable.
Click OK, click Yes to confirm that you want to make the change, and then click OK again.