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

Element not found

5 Answers 181 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
adhy
Top achievements
Rank 1
adhy asked on 07 Oct 2015, 11:20 PM

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

5 Answers, 1 is accepted

Sort by
0
adhy
Top achievements
Rank 1
answered on 07 Oct 2015, 11:54 PM

productGrid is found to have null value when i tried this

app.Find.Strategy = FindStrategy.WhenNotVisibleReturnNull;

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

 

0
Boyan Boev
Telerik team
answered on 12 Oct 2015, 10:39 AM
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
 
0
adhy
Top achievements
Rank 1
answered on 14 Oct 2015, 01:44 AM

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

0
adhy
Top achievements
Rank 1
answered on 16 Oct 2015, 05:17 AM

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.

0
Ivaylo
Telerik team
answered on 16 Oct 2015, 10:08 AM
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
 
Tags
General Discussions
Asked by
adhy
Top achievements
Rank 1
Answers by
adhy
Top achievements
Rank 1
Boyan Boev
Telerik team
Ivaylo
Telerik team
Share this question
or