Silverlight - Clicking on items

5 posts, 0 answers
  1. Rob Lange
    Rob Lange avatar
    23 posts
    Member since:
    Apr 2010

    Posted 19 Apr 2010 Link to this post

    I have a SilverlightApp inside an iframe. I never had any trouble clicking on the items, but I recently added some content to the SilverlightApp's parent frame -- and now the clicks 'look' like they're off by that amount. Any ideas?

    While I've got you here, I also had a ComboBox question. I found the only way to get comboBox.Items to contain the full list of items was to click on it. Are there any easier ways? Refresh didn't work...

    int oldIndex = comboBox.SelectedIndex;  
     
    // Populate the Combobox, just to make sure everything is up to date.  
    comboBox.User.Click();  
    comboBox.SelectedIndex = 1;  
    comboBox.Refresh();  
    comboBox.User.Click();  
     
    if (oldIndex == -1)  
    {  
      // -1 index no longer exists  
      oldIndex = 0;  
    }  
     
    for (int index = 0; index < comboBox.Items.Count(); ++index)  
    {  
      ...  
  2. Rob Lange
    Rob Lange avatar
    23 posts
    Member since:
    Apr 2010

    Posted 19 Apr 2010 Link to this post

    The clicking on the wrong spot had to do with AJAX moving the silverlight control location after I'd already set my SilverlightApp object. So I fixed that.

    I'll play around with the ComboBox item population a little more tomorrow... feel free to toss some ideas my way.
  3. Rob Lange
    Rob Lange avatar
    23 posts
    Member since:
    Apr 2010

    Posted 20 Apr 2010 Link to this post

    It seems that setting
    Manager.ActiveBrowser.AutoDomRefresh = true;   

    Doesn't really work that well. For example, this line of code gives me the old position of the Silverlight control.
    manager.ActiveBrowser.AutoDomRefresh = true;  
    testGame = manager.ActiveBrowser.Frames.ById(WebAiiPageElements.GAMEFRAME).SilverlightApps()[0]; 

    Whereas, this code does give me the new location
    manager.ActiveBrowser.RefreshDomTree();  
    testGame = manager.ActiveBrowser.Frames.ById(WebAiiPageElements.GAMEFRAME).SilverlightApps()[0]; 

    I'm working with a lot of dynamic content... having to call Refresh on the DOM tree everytime I need to check a variable seems pretty insane. Here's another example of code that didn't work until I stuck RefreshDomTree into it...
    /// <summary>  
    /// Waits for the ad to finish loading  
    /// </summary>  
    /// <param name="manager">The WebAii manager.</param>  
    static public void ForWaitFinish(Manager manager)  
    {  
        // Temp code until they work out exactly how Ads will work  
        Element loadingStatus = manager.ActiveBrowser.Frames.ById(WebAiiPageElements.ADFRAME).Find.ById(WebAiiPageElements.Advertisement.LoadingStatusID);  
        while (loadingStatus != null)  
        {  
            System.TimeSpan waitTime = new System.TimeSpan(0, 0, 5);  
            System.Threading.Thread.CurrentThread.Join(waitTime);  
            manager.ActiveBrowser.RefreshDomTree();  
            loadingStatus = manager.ActiveBrowser.Frames.ById(WebAiiPageElements.ADFRAME).Find.ById(WebAiiPageElements.Advertisement.LoadingStatusID);  
        }  
  4. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 20 Apr 2010 Link to this post

    Hello Rob Lange,

    I'd like to start by clarifying for you some of the inner workings of the framework so that you can better understand how things are supposed to work.

    The AutoDomRefresh means that the framework will automatically take a snapshot of the browsers DOM after some significant event happens e.g. navigate step, button click, drop down selection, etc. The framework maintains a cached copy of the DOM for performance reasons. If we didn't the tests would run painfully slowly.

    Unfortunately this does have the bad side effect in that the frameworks cached copy can easly get out of sync with the browsers DOM with dynamic content such as what you're describing. Things like JavaScript running in the background do not trigger an event for us to hook into so that we know we need to refresh the cached copy of the DOM. I'll log a feature request for better support for web pages with heavy dynamic content.

    Regarding your combobox issue... is this a Silverlight or an HTML combobox? If it's Silverlight, I'm afraid what you're doing is probably the expected behavior. Frequently combobox's are databound and don't populate the Silverlight VisualTree until it's actually opened. It's the normal behavior of databound visual controls in Silverlight. If the elements (the combobox items) are not a part of the VisualTree we can't see them to work with them. Or is it an HTML combobox? If so, what is being used to populate it's list of items from the webserver?

    Sincerely yours,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Rob Lange
    Rob Lange avatar
    23 posts
    Member since:
    Apr 2010

    Posted 20 Apr 2010 Link to this post

    Thanks for the info, Cody. I now have a better understanding of how WebAii interacts with the DOM. I'll keep throwing that Update call all over the code until you guys find the perfect solution ;)

    With the ComboBox, I was talking about Silverlight. Having to click on it isn't the end of the world AND it looks like the only solution. But everything works after I click, so things could be worse.
Back to Top