Fail to find html element...

10 posts, 0 answers
  1. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 04 Jun 2015 Link to this post

    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

  2. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 09 Jun 2015 Link to this post

    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!
  3. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 29 Jul 2015 in reply to Ivaylo Link to this post

    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

     

     

     

  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 03 Aug 2015 Link to this post

    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!
  5. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 05 Aug 2015 in reply to Boyan Boev Link to this post

    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​

  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 07 Aug 2015 Link to this post

    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!
  7. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 13 Aug 2015 in reply to Boyan Boev Link to this post

    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

     

  8. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 14 Aug 2015 Link to this post

    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!
  9. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 14 Aug 2015 in reply to Boyan Boev Link to this post

    Hi Boyan,

    Problem finally solved and it works perfectly!!!

    Thank you!!!

    BR, Jurij

  10. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 17 Aug 2015 Link to this post

    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!
Back to Top