This is a migrated thread and some comments may be shown as answers.

Can not find attribute on firefox

1 Answer 14 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ha
Top achievements
Rank 1
Ha asked on 25 Jul 2012, 09:00 AM
Hi
Currently, I use customized code to find object
But on firefox , I can not find it. I see log file, count of htmlCollection =0
 public void DeleteSheet_CodedStep()
        {
            object sheetName = GetExtractedValue("SheetName");
             
            Assert.IsNotNull(sheetName, "variable SheetName on calling method is not defined");
             
            string sheetNameString =  (sheetName as string).Trim();
             
            Log.WriteLine(string.Format("{0} variable is defined", sheetNameString));     
             
            sheetNameString = Utility.HandleLongString(sheetNameString);
            
            Log.WriteLine(sheetNameString);
            
            sheetNameString = Utility.HtmlEncode(sheetNameString);
            
            Log.WriteLine(sheetNameString);   
            
            HtmlDiv htmlDiv = Find.ById<HtmlDiv>("dnn_ctr431_ViewMediaResource_UP");  
            
            Log.WriteLine("htmlDiv"+htmlDiv);
            
            //Add find on firefox until find out result
   /*         if (ActiveBrowser.BrowserType == BrowserType.FireFox || ActiveBrowser.BrowserType == BrowserType.Chrome )
            {
                while (htmlDiv == null)
                {
                    ActiveBrowser.RefreshDomTree();
                    htmlDiv = Find.ById<HtmlDiv>("dnn_ctr431_ViewMediaResource_UP");
                }
            }
    */
            
            IList<HtmlDiv> htmlDivsCollection = htmlDiv.Find.AllByAttributes<HtmlDiv>("class=body-component");

    /*        if (ActiveBrowser.BrowserType == BrowserType.FireFox )
            {
                while (htmlDivsCollection.Count() == 0)
                {
                    ActiveBrowser.RefreshDomTree();
                    htmlDivsCollection = htmlDiv.Find.AllByAttributes<HtmlDiv>("class=body-component");
                }
            }
    */
            
            Log.WriteLine(string.Format("{0} html div count found", htmlDivsCollection.Count.ToString()));
            
            foreach(HtmlDiv listItem in htmlDivsCollection)
            {
                IList<HtmlDiv> contentColletion = listItem.Find.AllByAttributes<HtmlDiv>("class=body-component-content");
                
                Log.WriteLine(contentColletion[0].TextContent);
                
                if (String.Compare(sheetNameString, contentColletion[0].TextContent) == 0)
                {
                    Log.WriteLine("mediaSheet found");
                    
                    IList<HtmlControl> default_sheet = listItem.Find.AllByAttributes<HtmlControl>("class=body-component-menu-delete");
               
                    if(default_sheet != null && default_sheet.Count > 0)
                    {
                        Log.WriteLine(string.Format("language tile object {0} deleted", sheetNameString));
                        listItem.MouseHover();
                        default_sheet[0].MouseClick();
                    }
                    
                    break;
                } 
Please refer attachment
Thanks so much

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 30 Jul 2012, 08:24 AM
Hello,
you state that the count of the htmlCollection as seen in the Log is zero. I assume you're referring to the following line of code:
Log.WriteLine(string.Format("{0} html div count found", htmlDivsCollection.Count.ToString()));

The code that gets this collection is:
IList<HtmlDiv> htmlDivsCollection = htmlDiv.Find.AllByAttributes<HtmlDiv>("class=body-component");

I assume the issue is that this code successfully returns a collection with some members in IE but fails to do so in FF. Is this correct?

If so, we need to determine why that is. What you can do is examine the DOM structure of your application under FF. The way to do that is to use the debugger we have in Standalone. From there you can do a simple search in the DOM to find whether any elements match the condition:
class=body-component
If no elements turn up - you'll immediately know why the collection is turning up empty in FF.

Here's a video demonstrating how to do the above-described sequence:
http://screencast.com/t/g32mMzNf

I hope this helps. Let me know if you're still unable to make progress on this.

All the best,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Ha
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or