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

Fail to find html element...

9 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jurij
Top achievements
Rank 2
Jurij asked on 04 Jun 2015, 09:55 AM

Hi,

I'm having trouble to understand why extracting and then verifying some element doesn't work:

1. Extract selection 'ByText' on 'Cat274411276264076Select' into DataBindVariable $(ticketSumNr)

2. Click 'SubmitPerformanceTopButtonTag'

3. Verify 'InnerText' 'StartsWith' '4' on 'x4TicketsTableCell' - DataDriven: [$(ticketSumNr)]

In short, I reserve random number of tickets, extract this number and then check in the checkout process if number tickets is the same.

When runing the test case I get the following error:

Unable to locate element. Details: Attempting to find [Html] element using Find logic
 (Html): [tagname 'Exact' td] AND [TextContent 'Exact' 4 tickets]

Unable to locate element. Search failed!

Why does this happen and what I'm doing wrong?

BR, Jurij

9 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 09 Jun 2015, 06:47 AM
Hello Jurij,

I cannot tell why the element cannot be found without having your application. May be the element has dynamic attributes.
You'll need to change the find logic of the element as shown in this article and use more robust find logic.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Jurij
Top achievements
Rank 2
answered on 29 Jul 2015, 09:43 AM

Hi Ivaylo,

I finally am able to search through page elements  and I do get the desired results. However I have problem to use those attributes, for example I have WebSales2 page element and attributes like Cat​1Select, Cat2Select and Cat​3Select. Now if I record choosing value 1 from attribute Cat1Select it looks like something like this in the code:

Pages.FindEventsWebSales2.Cat1Select.AsjQueryControl

Now all other attributes are not listed in the element view, but only Cat1Select. With search I can find all of them, but how can I use them like:

Pages.FindEventsWebSales2.Cat2Select.AsjQueryControl

or

Pages.FindEventsWebSales2.Cat3Select.AsjQueryControl

and so on?

If I add them manually with highlight options like Add to elements, then I get them in elements view. Is it possible to do something like this using code and how?

BR, Jurij

 

 

 

0
Boyan Boev
Telerik team
answered on 03 Aug 2015, 07:16 AM
Hi Jurii,

I am not sure if I understand you correctly.

What type of controls are  Cat1Select , Cat2Select e.t.c. In order to have a element in the Element explorer you should record some step against it.

Let me know if I am missing something. Some screen shots or video would help us better understand your issue.

Thank you.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Jurij
Top achievements
Rank 2
answered on 05 Aug 2015, 11:09 AM

Hi Boyan,

I have started to work from scratch on the same project, but this time using C# instead of VB.NET (far greater support within the company). Now for the same topic, I get the following error, where everything seems to be OK:

 

Line 55: (CS0246) The type or namespace name 'HTMLFindExpression' could not be found (are you missing a using directive or an assembly reference?)
Line 55: (CS0246) The type or namespace name 'HTMLFindExpression' could not be found (are you missing a using directive or an assembly reference?)

Code:------------------------------------------------------------
using Telerik.TestingFramework.Controls.KendoUI;
using Telerik.WebAii.Controls.Html;
using Telerik.WebAii.Controls.Xaml;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

using ArtOfTest.Common.UnitTesting;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using ArtOfTest.WebAii.Design;
using ArtOfTest.WebAii.Design.Execution;
using ArtOfTest.WebAii.ObjectModel;
using ArtOfTest.WebAii.Silverlight;

using ArtOfTest.WebAii.Silverlight.UI;

...

// Create an HTMLFindExpression element

{
HTMLFindExpression expr = new HTMLFindExpression("name=^cat[");

// Return all elements matching HTMLFindExpression
IList<HtmlSelect> allSams = Find.AllByExpression(expr);

System.Random random = new System.Random();
int randomNr = random.Next(0, allSams.Count);
    
allSams[randomNr].SelectByValue("2", true);
}
Code:------------------------------------------------------------

Line 55 is: HTMLFindExpression expr = new HTMLFindExpression("name=^cat[");

Can you tell me what could be wrong here?

BR, Jurij​

0
Boyan Boev
Telerik team
answered on 07 Aug 2015, 02:36 PM
Hello Jurii,

The methods and classes in OOB programming are case sensitive.

Please change your code as follows:

HtmlFindExpression expr = new HtmlFindExpression("name=^cat[");

Let me know if that helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Jurij
Top achievements
Rank 2
answered on 13 Aug 2015, 08:31 AM

Hi Boyan,

Thanks, this was the reason all along. Error should been more descriptive, but I guess this is MS fault. Next error I get now is:

Add to cart.tstest.cs: Line 59: (CS0266) Cannot implicitly convert type 'System.Collections.ObjectModel.ReadOnlyCollection<ArtOfTest.WebAii.ObjectModel.Element>' to 'System.Collections.Generic.IList<ArtOfTest.WebAii.Controls.HtmlControls.HtmlSelect>'. An explicit conversion exists (are you missing a cast?)

Code from line 59 is as follows (I expanded code view to see the code in this line):

// Return all elements matching HtmlFindExpression name
IList<HtmlSelect> allSams = Find.AllByExpression(expr);

Can you see what is wrong now?

BR, Jurij

 

0
Boyan Boev
Telerik team
answered on 14 Aug 2015, 08:12 AM
Hi Juri,

When you define the type of the IList you should use also <TControl> method.

Your code should look like:

IList<HtmlSelect> allSams = Find.AllByExpression<HtmlSelect>(expr);

Hope this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Jurij
Top achievements
Rank 2
answered on 14 Aug 2015, 08:40 AM

Hi Boyan,

Problem finally solved and it works perfectly!!!

Thank you!!!

BR, Jurij

0
Boyan Boev
Telerik team
answered on 17 Aug 2015, 01:52 PM
Hi Jurii,

I am happy to hear that!

If you need further assistance please let us know.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Jurij
Top achievements
Rank 2
Answers by
Ivaylo
Telerik team
Jurij
Top achievements
Rank 2
Boyan Boev
Telerik team
Share this question
or