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

Invoke OnClick event timing out

19 Answers 265 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 24 Jan 2012, 09:59 PM
Hello, I am creating a test for my company's WCM application and when I add the invocation of the OnClick event on an HTML element, the step just hangs once the OnClick finishes.

I have looked everywhere and was unable to find a solution to this issue.  Any help would greatly be appreciated. 

Exception message follows:

ArtOfTest.Common.Design.Exceptions.ExecutionException: Wait for condition has timed out ---> System.TimeoutException: Wait for condition has timed out
   at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo)
   at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout, WaitResultType errorResultType)
   at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout)
   at ArtOfTest.WebAii.Core.Browser.WaitUntilReady()
   at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
   at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
   at ArtOfTest.WebAii.Core.Actions.InvokeEvent(Element targetElement, ScriptEventType eventType)
   at ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.InvokeEventActionDescriptor.Execute(Browser browser)
   at ArtOfTest.WebAii.Design.Extensibility.HtmlActionDescriptor.Execute(IAutomationHost autoHost)
   at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep(Int32 order)
   --- End of inner exception stack trace ---

19 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 25 Jan 2012, 06:19 PM
Hello Jonathan,

This is difficult to diagnose out of context. Please use the Export Result to File feature from the Step Failure Details to provide more information.

Have you tried changing that step's SimulateRealClick Test Step Property to True?

Greetings,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 25 Jan 2012, 07:38 PM
Hi Anthony, attached please find the export.

Please note that the invoke JS OnClick event does not have a 'Simulate real click' property in Test Studio. Is there a way to do it via a coded step?
0
Anthony
Telerik team
answered on 25 Jan 2012, 09:46 PM
Hello Jonathan,

Thank you for the additional files.

Sorry for the confusion; I actually meant disabling the JavaScript OnClick step and using a basic Click step in its place. Then set that Click step to SimulateRealClick to True.

I tested this against this W3 Schools demo page, and both a standard Click step and Invoke OnClick step worked to copy the text. I don't see an OnClick attached to the "Properties" link in your DOM, however:

<H2 id=wcmTab_t2-tab class=tab><A href="#">Properties</A></H2>

So perhaps a standard Click step, or a Left Click Mouse Action from the Elements Menu, is the way to go.

Greetings,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 25 Jan 2012, 09:49 PM
Anthony, I tried the regular click, as well as the simulate real click and both of them were not working as expected.

I will try the left click and see if that works.
0
Jonathan
Top achievements
Rank 1
answered on 25 Jan 2012, 10:05 PM
Left mouse click did not work either.

So far the only one that does what it is suppose to is the OnClick event.  But then it times out after.
0
Anthony
Telerik team
answered on 25 Jan 2012, 11:30 PM
Hello Jonathan,

Can you grant us direct access to your site so we can test this directly? If not, can you provide a public site that demonstrates the same behavior?

When you say the clicks don't work, do you mean that step fails? Or does the click occur yet the expected page state does not change?

Another idea is to Invoke a Blind Mouse Click, and base that click on a consistent reference element.

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 26 Jan 2012, 02:46 PM
Hi Anthony, when I invoke the OnClick method I get the result I need, but unfortunately it seems that Telerik is waiting for a response from the browser, which it wont get as the page is being updated via javascript and AJAX.

Unfortunately, the websites I am testing are all internal to our organization and there are no public sites with the same behavior.
0
Anthony
Telerik team
answered on 26 Jan 2012, 04:32 PM
Hello Jonathan,

Now that you mention an AJAX postback, try Waiting for the AJAX Postback to Complete with a coded step. This ensures synchronization with the postback event.

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 26 Jan 2012, 04:49 PM
Thanks Anthony, should the coded step go before or after the invocation of the OnClick?
0
Jonathan
Top achievements
Rank 1
answered on 26 Jan 2012, 05:01 PM
Anthony, I tried putting the postback confirmation code after the OnClick step I have and it still didnt work.

It seems that the OnClick is happening, but it seems as if it is waiting for a response before moving to the next step.
0
Accepted
Jonathan
Top achievements
Rank 1
answered on 26 Jan 2012, 07:24 PM
Anthony, FYI, the solution was to set the closesBrowser parameter to true when I called InvokeEvent.
0
Siva
Top achievements
Rank 1
answered on 18 Jun 2012, 04:41 PM
Hi Jonathan
 I have the Same Problem I'm New to Telerik and C#, Could you send sample code

I've converted my recored click step into coded step
When execute i'm Getting error
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step: '[WebTest2_CodedStep] : @"Click 'TestNewUserLink0''.
InnerException:
System.TimeoutException: Wait for condition has timed out
   at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo)
   at ArtOfTest.Common.WaitSync.For[T,V](Func`3 func, T target, V custom, Boolean invertCondition, Int32 timeout)
   at ArtOfTest.WebAii.Synchronization.Wait.ForCondition(Func`3 condition, Boolean invertCondition, Object custom, Int32 timeout)
   at ArtOfTest.WebAii.Synchronization.Wait.ForExists(Int32 timeout, Boolean refreshElement)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get(HtmlFindExpression expr, Boolean waitOnElement, Int32 timeout)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get(HtmlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](HtmlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](String[] clauses)


0
Anthony
Telerik team
answered on 18 Jun 2012, 06:17 PM
Hello Siva,

Let's continue with the W3Schools demo page example. Using the JavaScript Events feature from the Elements Menu, you can record the following step against the Copy Text button:

  • Invoke 'OnClick' event on 'CopyTextButtonTag'

It appears you recorded an actual click step against your "Test New User" Link. Record an OnClick step instead from the Elements Menu.

Jonathan converted the OnClick step to code. In our example it becomes this:

// Invoke 'OnClick' event on 'CopyTextButtonTag'
Pages.TryitEditorV151.FrameView.CopyTextButtonTag.InvokeEvent(ArtOfTest.WebAii.Core.ScriptEventType.OnClick);

And to bypass the "wait for a response before continuing," he set the closesBrowser boolean to True:

Pages.TryitEditorV151.FrameView.CopyTextButtonTag.InvokeEvent(ArtOfTest.WebAii.Core.ScriptEventType.OnClick, true);


Greetings,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Siva
Top achievements
Rank 1
answered on 21 Jun 2012, 04:20 PM
Hello Antony

 Thank You for sending me a Reply, I tried this w3schools copy text with code also without code just by recording steps. Its working fine.

my Scenarios is, I will create the Users and it is listed under the User Tab

If i click particular user in my Example( TestNewUser) , It should Navigate nextpage with that users Details.

What happend is If i record the click for(TestNewUser), Its added to the Elements(DOM) with the Properties

Findlogic = [href 'Exact' /MembershipAdministration/UserDetails/userID= "somenumbers"] AND [InnerText 'Exact' Test_User] AND [TagName 'Exact' a]

Expression = TagName=a,href 'Exact' /MembershipAdministration/UserDetails/userid = "somenumbers " ,InnerText=Test_User

So If i run the test , its linke anotherclick, so that userid="somenumbers" doesn't match with previous, gives error "href...." no elementfound

This is the issue
0
Anthony
Telerik team
answered on 22 Jun 2012, 06:40 PM
Hello Siva,

This is a separate issue. It sounds like you need a Data Driven Find Expression. In other words, if your new user creation is Data Driven, then you can use the data value of the current iteration to find the link that is subsequently created.

Since you currently cannot data drive through the Find Element dialog, you can instead use a couple lines of code to accomplish this. The last sample on this page shows an example:

HtmlAnchor a = Find.ByExpression<HtmlAnchor>("tagname=a", "innertext=" + Data["Col1"].ToString());
a.Click();

If you're not data driving, you can perform an Extraction and then Access the Extracted Variable in code and use it in the coded find logic.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Siva
Top achievements
Rank 1
answered on 25 Jun 2012, 04:28 PM
Anthony,

  I have Username in Xl file. I did the Data Driven for username, With that I've Craeted a new User, Its Listed in the Page.
When I click that user it will navigate to the User Details Page, To do that I've used
HtmlAnchor a = Find.ByExpression<HtmlAnchor>("tagname=a", "innertext=" + Data["Username"].ToString());
a.Click();


Now, In the NAvigated Page, I've Link "DeleteUser", If Click that, User should be deleted, I tried the Same abovecode for "deleteuser"

System.NullReferenceException: Object reference not set to an instance of an object.

Can't i use the same htmlanchor for deleteuser?



Also Another question, If there is no data driven How should the click works with the find expression

            HtmlAnchor a = Find.ByExpression<HtmlAnchor>("tagname = a" ,"InnerText = Test_Admin","TextContent=Test_admin");
      
            a.Click();


Click 'TestAdminLink3''. ---> System.NullReferenceException: Object reference not set to an instance of an object.
0
Anthony
Telerik team
answered on 25 Jun 2012, 10:09 PM
Hello Siva,

1. Yes, you can reuse that code, however you'll probably need to edit it to indicate a partial match. Currently it's written to find an exact match and if the InnerText does not match the data value exactly, the link won't be found.

Use a tilde (~) to indicate a partial match:

HtmlAnchor a = Find.ByExpression<HtmlAnchor>("tagname=a", "innertext=~" + Data["Username"].ToString());
a.Click();

2. You'll probably need to search based on partial match when not data driving as well. Also it's rare that you'd need to use InnerText and TextContent. Pick the one that best suits how your page's HTML is formatted. See here for more information on validation content element types.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Siva
Top achievements
Rank 1
answered on 26 Jun 2012, 03:10 PM
Hello Anthony

Thank you so much for you help,

If i delete the user, I have to go back and have to verify the list items, it appears like,  
Users

1 -> All of the application's users are listed below. Click here to create a new user.

  1. User1
  2. User2
  3. User3

If i click the user1 -> goes to details page -> there i have option to delete -> when i comeback, i have to verify user1 is not in the list,

i tried to use with quick task, but it didn't worked out  well.

2 -> i need to verify the Table(just html table tag with <tr> <td> ) in some other page. for example

The following is a list

  Name Description Additional Info Action
Portfolio 1 p1
TestPortfolio AutomateTestPortFolio

If i want to delete the second one, How to verify the "Name" to that corresponding click ( Its actually long list, i may want any row delete, each row has delete button)
I appreciate your suggestion.
0
Anthony
Telerik team
answered on 27 Jun 2012, 04:46 PM
Hello Siva,

1. Try targeting the parent <ol> or <ul> element to base your verification (find it directly in the DOM), as demonstrated in this article. This assumes you're dealing with an actual Ordered or Unordered List. If not, there's likely a parent <div> you can target instead.

2. See the following code sample:

//Identify the table. This may need to be modified based on your page layout.
HtmlTable table = Find.ByExpression<HtmlTable>("TagIndex=table:0");
Assert.IsNotNull(table);
 
//Access the row with matching text. The InnerText can be data driven.
HtmlTableRow row = table.Find.ByExpression<HtmlTableRow>("innertext=~TestPortfolio", "tagname=tr");
 
//Access the fourth cell in that row.
HtmlTableCell cell = row.Cells[3];
 
//Access the "Delete" link in that cell.
HtmlAnchor a = cell.Find.ByExpression<HtmlAnchor>("innertext=~Delete", "tagname=a");
a.Click();


For future reference, please file a separate support ticket or forum post for new issues. This ensures better tracking and responses for both parties.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Jonathan
Top achievements
Rank 1
Siva
Top achievements
Rank 1
Share this question
or