Telerik Forums
Testing Framework Forum
11 answers
641 views

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

Jeffery
Top achievements
Rank 1
 answered on 27 Feb 2012
1 answer
211 views
Hello, 

i am trying to set & get a cookie, without success.
my code:

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;

count is always == 0!

I am on the latest release of the (free) testing framework.
ActiveBrowser is Chrome.

If I set ActiveBrowser to IE, it works!

Am I doing anything wrong?

Thanks.

Cody
Telerik team
 answered on 25 Feb 2012
2 answers
122 views
Hi

I'm having problems installing the testing framework on my virtual machine.

Server:
Windows 2008 R2 Standard - Service pack 1

.NET framework installed:
Microsoft .NET Framework 4 Client Profile
Microsoft .NET Framework 4 Extended
Microsoft .NET Framework 4 Multi-Targeting Pack

I'm getting an error about not having 3.5, but shouldn't that be apart of the 4?
Martin
Top achievements
Rank 1
 answered on 24 Feb 2012
1 answer
152 views
Hello ,

I'm using the following code to obtain the canvas object:

var bar1 = Find.ById<HtmlCanvas>("bar1");

my question is , how can I verify the content in this object ?

for example of my code:
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();

How can I verify the "chart" since i got the HtmlCanvas object ?

Thanks,
Hanson Wang
Plamen
Telerik team
 answered on 23 Feb 2012
3 answers
76 views

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.

Cody
Telerik team
 answered on 22 Feb 2012
1 answer
118 views
Hi Team,

Mine is web application -- i have scenario-- where it will direct user to popoup window by clicking lookup icon in the mainpage.
in popup window-- i need to choose value which is tree table -- refer application image.
by double clicking the text the the child node can be selected.  --- now i need bind the data from global data source.

i don't how to bind the data for tree table mouse click event.

i try to find the text from the tree table but i couldn't
please refer the dom image which i attached, and also refer ui1 image.

do the need full
thanks,
Bharathi Muruhappan.

Plamen
Telerik team
 answered on 21 Feb 2012
4 answers
152 views
Hi

I am attempting to use the testing framework to write an UI test that is using the RadCombobox, However I am having trouble and looking for pointers in where I am going wrong. This may be the first of many posts ;-)

For this post, I am using this page for testing purposes: http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx

I have test class set up, and what I am attempting to do is search for a company, and then select the company from the list, however, I cannot get the number of items in the combobox after doing the filter.

This is an asp.net combobox, not silverlight. I am using the latest version of nunit, telerik asp.net and testing framework. I have viewed the samples for the test framework, but all the samples that I saw are testing this page: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/keyboardsupport/defaultcs.aspx and dont appear relevant for what I want to do.

This is the test to indicate by problem: I have excluded setup and teardown for brevity.
[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);
}


I cannot get past the assert to ensure that 4 items have been returned, as the value returned is always 0.

I know I have missed something simple. Thanks in advance

Darren
Anthony
Telerik team
 answered on 20 Feb 2012
6 answers
144 views
Hello everybody,
I encountered an issue during automation testing like that:
There is a custome control with the type of "SelectableTextBlock" in our silverlight app, the text of which is "jkljljkljljl". In my test code, I need to retrieve the value of the text, but the valued is empty after extecute , so I need your help. My test code is below:
FrameworkElement tbContent = lstBBSReplyItem[i].Find.ByType("SelectableTextBlock");
console.WriteLine(tbContent.TextLiteralContent);

Attached image is the custome control and the value of it's text.

Thanks!!
Lucia

lucia
Top achievements
Rank 1
 answered on 17 Feb 2012
28 answers
465 views
Hi,

Am i able to automate custom controls like below
[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();  
                    } 

My Custom Control
public partial class MyCustomControl : UserControl  
    {  
        public MyCustomControl()  
        {  
            InitializeComponent();  
        }  
 
        private void btnLogin_Click(object sender, RoutedEventArgs e)  
        {  
            MessageBox.Show("Custom Control");  
        }  
    } 
Cody
Telerik team
 answered on 16 Feb 2012
1 answer
321 views
Hi,

I am using WebAii 2011.1.

I want to send the key Ctrl-A to the framework element that I found.

According to the documentation:
   1) SendString is deprecated in favor of TypeText or KeyPress
   2) TypeText cannot send special characters

No sure how to use KeyPress for 2 keys that are simultaneous, ControlKey and the "A" key.

I tried this sequence but it did not work ( ie select all of the text in Framework Element )

   fe.User.KeyDown(Keys.ControlKey);
   fe.User.KeyPress(Keys.A,Constant.KeyDelay);
   fe.User.KeyUp(Keys.ControlKey);


The only article I could find uses SendString.
   http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/automation-framework/can-t-combine-shift-key-down-with-other-keys.aspx

Thanks,
Anthony
Telerik team
 answered on 15 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?