public void FileUpLoadDialogUsingAttributes() { // Cause the upload Dialog to pop-up // FileUploadDialog dialog = new FileUploadDialog(ActiveBrowser, "custom file path", DialogButton.OPEN); FileUploadDialog dialog = new FileUploadDialog(ActiveBrowser, string.Empty, DialogButton.CANCEL); Manager.DialogMonitor.AddDialog(dialog); Manager.DialogMonitor.Start(); // With Firefox, it is not allowed to pop the dialog using script due to security restrictions. if (ActiveBrowser.BrowserType == BrowserType.FireFox) { // invoke the dialog using a direct mouse click (Click 10 pixels to the left of the right edge of the control) Desktop.Mouse.Click(MouseClickType.LeftClick, this.Elements.GetHtml("uploadfile").GetRectangle(), new Point(-10, 0), OffsetReference.RightCenter); // Given that we are using pure UI outside the browser, let's make sure we wait for the browser to // be ready ActiveBrowser.WaitUntilReady(); } else { // just click it Actions.Click(this.Elements.GetHtml("uploadfile")); } dialog.WaitUntilHandled(); }
public void UploadUserAvatar() { BATFeather.Wrappers().Frontend().Identity().ProfileWrapper().ClickUploadPhotoLink(); string fullImagesPath = DeploymentDirectory + @"\"; var fullFilePath = string.Concat(fullImagesPath, FileToUpload); var uploadDialog = new FileUploadDialog(Manager.Current.ActiveBrowser, fullFilePath, DialogButton.OPEN); Manager.Current.DialogMonitor.AddDialog(uploadDialog); Manager.Current.DialogMonitor.Start(); uploadDialog.WaitUntilHandled(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.RefreshDomTree(); BATFeather.Wrappers().Frontend().Identity().ProfileWrapper().SaveChangesButton(); }
public static void Upload(Action action, string filePath) { Manager.Current.ActiveBrowser.Window.Maximize(); var dialog = new FileUploadDialog( Manager.Current.ActiveBrowser, filePath, DialogButton.OPEN, "OPEN"); try { Manager.Current.DialogMonitor.AddDialog(dialog); Manager.Current.ActiveBrowser.RefreshDomTree(); action(); dialog.WaitUntilHandled(); } finally { Manager.Current.DialogMonitor.RemoveDialog(dialog); } }