Hi is there any way to get link for file, when I click on Download button browser start to download file.
I have following html button tag.
<button type="button" ng-click="vm.handleClick(vm.item[1])">Download</button>
When I use this it only download file, is there any way to get link from ng-click event?
executor.ExecuteScript("arguments[0].click()", webElement);
Related
I'm using Puppeteer Sharp to test my web app. My web app has a button that triggers an <input type="file"> to let the user select a CSV file to upload.
How do I use that to upload a file when testing via Puppeteer Sharp? Just clicking the button isn't enough, because I need to give the browse-for-file dialog a path to the file.
You can use Page.WaitForFileChooserAsync to interact with the file chooser. The important thing to remember is you need to have the file chooser ready before you click the <input type="file">.
For example:
var fileChooserDialogTask = page.WaitForFileChooserAsync(); // Do not await here
await Task.WhenAll(fileChooserDialogTask, page.ClickAsync("input[type='file']"));
var fileChooser = await fileChooserDialogTask;
await fileChooser.AcceptAsync(pathToFile);
If you try to click the <input type="file"> before you've called WaitForFileChooserAsync, you'll be stuck with the modal file chooser dialog waiting for you to do something.
<div class="mdl-align"> == $0
: :before
<button class="fp-upload-btn btn-primary btn">Upload this file</button> == $0
: :after
</div>
The above codes are from a website, however I am unable to click this button despite trying multiple attempts. Im using selenium with C# to do an automation testing.
What this button does, is to simply submit a form.
Try to use xpath locator to click on Upload this file button.
driver.FindElement(By.XPath("//button[contains(text(), 'Upload this file')]")).Click();
I am using the .NET WebBrowser control to automate some web tasks, however now and again the website I am visiting will produce a dialogue box with a YES/NO button that I need to press.
The dialogue is popped up using a Javascript modal window. I need the WebBrowser to detect a Javascript modal popup, get the source of the popup to define the response to give, and then click one of the buttons.
Can this be achieved?
I've encountered a similar situation
But in my case it is just a simple confirm dialog so I simply skip it by removing the confirm javascript command from the html element.
Here's the javascript code that invoke the dialog
confirm('Comfirm to kill');
here's the full html tag of the button that invoke the dialog
<a id="inputID" onclick="return confirm('Comfirm to kill.');" href="javascript:__doPostBack('ctl00$ContentMainContent$gvOnlineUser$ctl02$btnAction','')">
And here I remove the js to call the function
HtmlElement elementButton = doc.GetElementById("inputID");
elementButton.SetAttribute("onclick", "return true;");
elementButton.InvokeMember("Click");
That should skip the confirmation dialog part
I'm not sure it would work in your case though
Hope this help anyway
I want to show up an OpenFileDialog box in my ASP .NET web application. I am writing in c#. I want to create a user account with an image so I need to select image from my computer and save it into a database. How can I implement it.
You can do that using
<input type="file" id="fileLoader" name="files" title="Load File" ...
The usual trick is to make it invisible, and on clicking some visible artifact (styled link, image, button... whatever) simulate a click on fileLoader:
$("#fileLoader").click();
You cannot. OpenFileDialog is something for desktop applications.
you cannot use that Windows Forms class in ASP.NET, you should use the FileUpload class/control.
Or see other alternatives: Uploading Files in ASP.net without using the FileUpload server control
Almost the same as Tigran's above but I found I needed to change the JavaScript slightly to use getElementById("...") to identify the button to click(). If I just did this in HTML/CSS Tigran's code worked fine but when I used it within an .aspx file I required the change.
.aspx
<input type="file" id="fileLoader" name="files" title="Load File" />
<asp:Button ID="LoginButton" runat="server" Text="ASP click Me" onclientclick="openfileDialog()" />
JavaScript
function openfileDialog() {
document.getElementById("fileLoader").click();
}
css
#fileLoader{
display:none;}
I have a uploadify plugin on my page and below it I have a description field and a textbox for it. I have submit button below it. Now my problem is uploadify will start async file upload as soon as you select file. I want the uploadify to start upload on click of submit button and also description field's value to be available on the server. I am aware that there is option where you can ask uploadify to start upload on the click of some button. But even if I do that the submit button click event will be fired and the upload will be lost. Should I use script manager and update panel (uploadify should not be inside update panel) so that when submit button click event is fired the page doesn't reset and the uploadify can continue its work. How do you all typically handle this?
Thanks in advance :)
To disable auto start of the file upload, add this setting to the config of the uploadify:
'auto' : false
To submit the values of the form to the server along with file you need to create a separate link or button that gets the data from the form and send it using the uploadifySettings function and then call uploadifyUpload().
Here is an example that will send the details of an MP3 file filled in a form by user.
<a onclick="$('#file_upload').uploadifySettings('scriptData', { 'artist':$('#t_artist').val(), 'album':$('#t_album').val() }); $('#file_upload').uploadifyUpload()" class="greenBtn">START UPLOAD</a>
Where #t_artist and $t_album are the IDs of the input fields in the form.