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

Element Not Found.

3 Answers 161 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
abhishek
Top achievements
Rank 1
abhishek asked on 03 Oct 2016, 06:12 AM

Hi All

I am using Telerik Test Studio for Automation Testing . I am facing issue related to "Element no found" .

I have added element ("Gateway Name") in the DOM and object that needs to be identified is available in one of the Cell, after rebuild project .. I run my test cases and I am getting an error "element not found".

Is there any other way to store element permanently in the DOM because I have added "Gateway Name" element so many times in the DOM.

Please provide the solution for identifying these dynamic objects

Regards

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 06 Oct 2016, 06:50 AM
Hello Abhi,

Let me explain how Test Studio locates an element. Test Studio uses an intelligent element identification scheme to auto-generate find expressions. When an element is ready to be added to the Elements Explorer, Test Studio tries to use the first item in the list (usually "id"). Using this criteria, if the item is unique for the entire page, the element is added, a find expression is created, and Test Studio stops evaluating.

However if some of the attributes in the find expression is dynamically generated and constantly changes with every reloading of the page Test Studio cannot find it anymore. When you record the element again Test Studio will add a new element because it has changed find criteria already. 

In order to overcome this change how the element is found. You should create a find expression only with static find rules (e.g. TextContent, ID e.t.c.).

Let me know if that helps. 

Regards,
Boyan Boev
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
inchis
Top achievements
Rank 1
answered on 04 Sep 2018, 03:37 AM

Hello,

I have to  code the way to find the list values for a list view as I am not relying the exact id for finding the element.

In my case ,

I tried regular expression to detect the element which is a trigger picker of a combo list. After clicking this , I have to find the list which is populated somewhere down in the dom tree. To identify this , I tried the following code.

             1. HtmlDiv assignee  =Pages.Https1013129.AssigntoInnerCtDiv.Find.ByExpression<HtmlDiv>("id=~trigger-picker");
             2. Console.WriteLine(assignee.ID);
             3. Thread.Sleep(10000);
             4. assignee.MouseClick(); 
             5. Thread.Sleep(10000);
             6. char[] hyphenSeparator = new char[] { '-' };
             7. String id =assignee.ID.Split(hyphenSeparator)[1];
             8. Console.WriteLine("Id" +id);
             9. string searchID= "id=combo-"+id+"-picker";
            10. Console.WriteLine("searchID--" +searchID);
            11.  Element  listElement =Manager.ActiveBrowser.Find.ByExpression(searchID);

             12.Console.WriteLine("listElement"+listElement);

         

 

Upon running the test , the click of the list arrow was done successfully and it printed the id value as 2215 in the console for line 8.

It also printed the value id=combo-2215-picker for line 10.

However the listElement is printed as empty , though it is available in the domtree(please find the attachment).

 

Please let me know what is missing from my end .

 

0
Elena
Telerik team
answered on 05 Sep 2018, 03:38 PM
Hi Inchis,

Thank you for the detailed description of the faced issue. 

Please find some additional notes how you could construct a find expression in code and how to use the Find.ByExpression() method after that. I hope this will be helpful for you. Though in case you need any further assistance please let me know! 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
abhishek
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
inchis
Top achievements
Rank 1
Elena
Telerik team
Share this question
or