Element not found

6 posts, 0 answers
  1. adhy
    adhy avatar
    5 posts
    Member since:
    Sep 2015

    Posted 07 Oct 2015 Link to this post

    Hi ,

    I am running few test scripts .Error i am getting is "element not found" for hyperlinkbutton,DataGrid,Listbox.I tried to find it by name as well as by type,but nothing works for me.I used silverlight spy to get the properties of the element.Attached is the details I got using silverlight spy.

    Below is the details of error

    <ErrorInfo>
                  <Message>Test method FF_TEST.FINDING threw exception: 
    ArtOfTest.Common.Exceptions.FindElementException: Element Not found!
    FindExpression used: 
    [name 'Exact' dgProduct ]
    </Message>
                  <StackTrace>    at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo, Object target)
       at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout, WaitResultType errorResultType)
       at ArtOfTest.WebAii.Silverlight.VisualWait.ForExistsInternal(Int32 timeout, Boolean invertCondition)
       at ArtOfTest.WebAii.Silverlight.VisualWait.ForVisible(Int32 timeout)
       at ArtOfTest.WebAii.Silverlight.VisualFind.ReturnOrThrow(FrameworkElement e, String throwMessage)
       at ArtOfTest.WebAii.Silverlight.VisualFind.ByName(String name)
       at ArtOfTest.WebAii.Silverlight.VisualFind.ByName[T](String name)
       
    </StackTrace>
                </ErrorInfo>

    my code is

    var productGrid = app.Find.ByName<ArtOfTest.WebAii.Silverlight.UI.DataGrid>("dgProduct");

    I tried below line as well

    var productGrid = app.Find.ByName("dgProduct").As <DataGrid> () ;

    it was noticed that productGrid variable is getting assigned with null value.

    Similar issue is found with other controls like hyperlinkbutton ,listbox and label 

    Please guide me to solve this issue

  2. adhy
    adhy avatar
    5 posts
    Member since:
    Sep 2015

    Posted 07 Oct 2015 Link to this post

    productGrid is found to have null value when i tried this

    app.Find.Strategy = FindStrategy.WhenNotVisibleReturnNull;

    var productGrid = app.Find.ByName("dgProduct").As <DataGrid> () ;

     

  3. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 12 Oct 2015 Link to this post

    Hi Adhy,

    You don't need to change the FindStrategy.

    Your code seems to be correct. Could you please try out this code also:

    SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
    app.RefreshVisualTrees();
    DataGrid productGrid = app.Find.ByName<DataGrid>("dgProduct");

    Let me know if that helped.

    Regards,
    Boyan Boev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  4. adhy
    adhy avatar
    5 posts
    Member since:
    Sep 2015

    Posted 13 Oct 2015 Link to this post

    Thanks for your reply. I tried your suggestion but no luck with that piece of code. getting same error.

    It has some problem in finding UI elements.I had the same problem with a label element.Attached is the details.below line of code gave element not found

    var la= app.Find.ByName<ArtOfTest.WebAii.Silverlight.UI.Label>("laaaaa").Find.ByType<ArtOfTest.WebAii.Silverlight.UI.TextBlock>();

    Below line resolved the issue

    var la= app.Find.ByName<ArtOfTest.WebAii.Silverlight.UI.ContentControl>("ContentControl").Find.ByType<ArtOfTest.WebAii.Silverlight.UI.TextBlock>();

    So can you guess what could be the basic problem with finding UI elements

  5. adhy
    adhy avatar
    5 posts
    Member since:
    Sep 2015

    Posted 16 Oct 2015 Link to this post

    Hi,

    I found the reason for failure

    login function is not taking test to homepage(where all UI elements like datagrid are present)

    below is my login code

     

    public static void WLogin()
            {

                var UserName = app.Find.ByType<ArtOfTest.WebAii.Silverlight.UI.TextBox>();// Locate Username
                UserName.Text = "XXX";

                var Password = app.Find.ByType<ArtOfTest.WebAii.Silverlight.UI.PasswordBox>();// Locate Password and enter valid password
                Password.Password = "XXXX";

                var Okbutton = app.Find.ByType("LoginForm").Find.ByName<ArtOfTest.WebAii.Silverlight.UI.Button>("loginButton").User.Click();
                
                myManager.ActiveBrowser.WaitUntilReady(); // Sucessful Login and wait for page to load​

    }

    Please let me know what i am doing wrong in this function so that test is not proceeding to home page after login.

  6. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 16 Oct 2015 Link to this post

    Hello Adhy,

    Let me interject into this ticket since Boyan is out of the office.

    From the information provided we cannot determine why the test is not running properly. Your code looks correct from what you have provided. We may need your test and access to your application in order to take a look.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top