Hi Telerik team,
I want to hand all Confirm and Alert dialogs in multiple
browsers (IE/Firefox/Chrome) automatically.
The following code is my implementation.
manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;public static void AddDialogHandlers(Manager manager, EventHandler dialogDisplayedHandler){ manager.DialogMonitor.RemoveDialogs(); //// Add dialog handler for ConfirmDialog. ConfirmDialog confirmDialog = ConfirmDialog.CreateConfirmDialog(manager.ActiveBrowser, DialogButton.OK); confirmDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomConfirmHandler); manager.DialogMonitor.AddDialog(confirmDialog); //// Add dialog handler for AlertDialog. AlertDialog alertDialog = AlertDialog.CreateAlertDialog(manager.ActiveBrowser, DialogButton.OK); alertDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler); manager.DialogMonitor.AddDialog(alertDialog); // Add more dialogs here... manager.DialogMonitor.Start(); } public static void MyCustomConfirmHandler(IDialog dialog){ dialog.HandlerDelegate = null; dialog.Handle(); dialog = null; Manager.Current.DialogMonitor.RemoveDialog(dialog); ConfirmDialog confirmDialog = ConfirmDialog.CreateConfirmDialog(Manager.Current.ActiveBrowser, DialogButton.OK); confirmDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomConfirmHandler); Manager.Current.DialogMonitor.AddDialog(confirmDialog);} public static void MyCustomAlertHandler(IDialog dialog){ dialog.HandlerDelegate = null; dialog.Handle(); dialog = null; Manager.Current.DialogMonitor.RemoveDialog(dialog); ConfirmDialog confirmDialog = ConfirmDialog.CreateConfirmDialog(Manager.Current.ActiveBrowser, DialogButton.OK); confirmDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler); Manager.Current.DialogMonitor.AddDialog(confirmDialog);}The dialogs are handled well in IE and Chrome, but both of them can't be handled correctly in Firefox.
In Firefox, the Confirm and Alert dialog just can be handled for the first time they display, and not handled any more from second time.
From debugging, I found that the MyCustomConfirmHandler and MyCustomAlertHandler methods are not invoked when the browser is Firefox. (They are invoked if the browser is IE or Chrome.)
Seems the Customized Dialog handle method does not work in Firefox.
So, is there anything else needs to do for
Confirm and Alert dialogs in Firefox?
I'm looking forward for your feedback. Thanks.
Regards,
Jeffery
const string domain = "http://localhost"; var cookie = new Cookie("foo", "bar", "/", domain);var ok = telerik.ActiveBrowser.Cookies.SetCookie(cookie);var c = telerik.ActiveBrowser.Cookies.GetCookies(domain); var count = c.Count;bar3 = new RGraph.Bar('bar1', [health, warning, totalServer - health - warning]);bar3.Set('chart.labels', ['Health', 'Warning', 'Error']);bar3.Set('chart.tooltips', function (idx) { return '<b>' + bar3.Get('chart.labels')[idx] + '</b>'; });bar3.Set('chart.colors', ['green', 'gold', 'red']);bar3.Set('chart.colors.sequential', true); //bar3.Set('chart.title', 'Total Instances');bar3.Set('chart.hmargin', 28);bar3.Set('chart.labels.above', true);bar3.Set('chart.title.xaxis.size', 3);bar3.Draw();I can open the main login page, and login, however attempting to run a find for an element is failing. Snippet of code in VB:
Public Shared Function WebTagExistsTelerik(ByVal id As String, Optional ByVal browserOrdinal As Integer = 0, Optional ByVal frameOrdinal As Integer = 0, Optional ByVal frameName As String = "", Optional ByVal loglevel As Integer = 3) As Boolean Dim mngr = ScriptLibrary.Globals._BrowserManager Dim myElement As Element = Nothing For Each Brow In mngr.Browsers 'Brow.WaitUntilReady() Brow.RefreshDomTree() Try Brow.Frames.RefreshAllDomTrees() Catch ex As Exception End Try Next If id.ToUpper.StartsWith("NAME:") Then myElement = mngr.Browsers(browserOrdinal).Frames(frameOrdinal).Find.ByName(id.Replace("NAME:", "")) Else myElement = mngr.Browsers(browserOrdinal).Frames(frameOrdinal).Find.ById(id) End If myElement comes back as nothing, as it appears that the DomTree is still our login page. After logging in the page is embedded in a frame.
The WaitUntilReady, RefreshDomTree and RefreshAllDomTrees commands seems to be timing out and not actually refreshing. This code is working in Firefox. Any suggestions?
If I pause the execution before reaching this point and get the outermarkup of frame(0) it doesn't contain the information I would be expecting. It seems to only contain script tags, not any of the HTML expected from the framesrc.
[Test]public void SearchForCompany(){ string companyToSearchFor = "H"; RadComboBox comboBox = browser.Find.ById<RadComboBox>("RadComboBox1"); comboBox.Click(); comboBox.Text = companyToSearchFor; comboBox.ShowDropDown(); browser.WaitUntilReady(); browser.RefreshDomTree(); var comboboxItems = comboBox.Items; Assert.That(comboboxItems.Count, Is.EqualTo(4)); comboBox.SelectItemByIndex(1);}FrameworkElement tbContent = lstBBSReplyItem[i].Find.ByType("SelectableTextBlock");console.WriteLine(tbContent.TextLiteralContent);| [TestMethod] |
| public void LocalSilverlightTest() |
| { |
| Manager.LaunchNewBrowser(BrowserType.InternetExplorer); |
| ActiveBrowser.NavigateTo("http://localhost:1031/SampleSilverlightAppTestPage.aspx"); |
| SilverlightApp app = ActiveBrowser.SilverlightApps()[0]; |
| Assert.IsNotNull(app); |
| SampleSilverlightApp.MyCustomControl ctrl = app.Find.ByName<SampleSilverlightApp.MyCustomControl>("myCustomControl"); |
| Button btn = myCustomControl.Find.ByName<Button>("btnLogin"); |
| btn.User.Click(); |
| } |
| public partial class MyCustomControl : UserControl |
| { |
| public MyCustomControl() |
| { |
| InitializeComponent(); |
| } |
| private void btnLogin_Click(object sender, RoutedEventArgs e) |
| { |
| MessageBox.Show("Custom Control"); |
| } |
| } |