This question is locked. New answers and comments are not allowed.
I have a test page with some Telerik editors and at the bottom of the page a submit button. I have a test that clicks the button that works fine. I then created a new test that uses a custom dialog on an editor and then clicks the button. When I run the test it is not clicking the button after the custom dialog closes. I put in a delay after the custom dialog closes but still no click. I can see that Find.ByExpression is finding the button but when I call the Click method on it this is not happening.
Has anyone experienced this and know what I can do to get this working?
Has anyone experienced this and know what I can do to get this working?
5 Answers, 1 is accepted
0
Vyrban
Top achievements
Rank 1
answered on 21 Oct 2009, 06:08 AM
Is there any FormDecorator on the page or did the button decorated after you close the dialog, because then you can find it as an element but can exploit it. Also is better if you send a test, to see your scenario and if it possible - the page with Editors.
0
woaksie
Top achievements
Rank 2
answered on 21 Oct 2009, 05:10 PM
I am not sure what you mean by decorator. The editor is on a user control and added to a page dynamically. The page has a submit button that is not part of the editor. When the button is clicked it reads the contents of the editor (via the user control) and outputs it else where on the page. This is purely a tester page. I am writing WebAii tests against that page.
There is too much code in various files to post here, but I will post the test. The various components of the test work on their own in other tests but not when combined into this:
[Test]
public void ClickNewLinkButtonAndSelectJesse()
{
NavigateToTestPage("ClickNewLinkButtonAndSelectJesse");
RadEditor ed2 = Find.ByCustom<RadEditor>(a => a.ID.EndsWith("MqTelerikEditor"));
Assert.IsNotNull(ed2, "Did not find the editor");
// this is the button that fails at the end of the test. This click works but the one at the end of the test does not.
// and if I take this click out is still does not work at the end.
HtmlInputSubmit button = GetProcessButton();
button.Click();
HtmlDiv div = GetOutputDiv();
Assert.AreEqual("Well hello peeps", GetText(div), "Should be the peeps message");
OpenLinkerWindow(ed2);
IList<HtmlForm> sections = GetFormOfImageManagerTopSection(); // custom dialog has two frames
Assert.IsNotNull(sections, "Did not find form");
Assert.AreEqual(2, sections.Count, "Should be 2 elements");
// find a anchor link and click it
HtmlFindExpression findAnchors = new HtmlFindExpression();
findAnchors.AddClause("TagName=A");
ReadOnlyCollection<Element> expression = sections[1].Find.AllByExpression(findAnchors);
IEnumerable<HtmlAnchor> enumerable = expression.Select(a => new HtmlAnchor(a));
foreach (HtmlAnchor anchor in enumerable)
{
if (!anchor.InnerText.Contains("jesse"))
continue;
anchor.Click();
break;
}
sections = GetFormOfImageManagerTopSection();
var findButtons = new HtmlFindExpression();
findButtons.AddClause("TagName=input");
findButtons.AddClause("type=submit");
findButtons.AddClause("value=~Insert");
var insertButton = new HtmlInputSubmit(sections[0].Find.ByExpression(findButtons));
insertButton.Click(); // this button click closes the custom dialog
Thread.Sleep(4000); // just checking that it was not a timing issue
// this is the button click that does not work in this test.
Click(button); // I tried fetching the button at this point in the code but that didn't work either
div = GetOutputDiv();
Assert.AreEqual("Expected Text", GetText(div), "Editor text wrong");
}
There is too much code in various files to post here, but I will post the test. The various components of the test work on their own in other tests but not when combined into this:
[Test]
public void ClickNewLinkButtonAndSelectJesse()
{
NavigateToTestPage("ClickNewLinkButtonAndSelectJesse");
RadEditor ed2 = Find.ByCustom<RadEditor>(a => a.ID.EndsWith("MqTelerikEditor"));
Assert.IsNotNull(ed2, "Did not find the editor");
// this is the button that fails at the end of the test. This click works but the one at the end of the test does not.
// and if I take this click out is still does not work at the end.
HtmlInputSubmit button = GetProcessButton();
button.Click();
HtmlDiv div = GetOutputDiv();
Assert.AreEqual("Well hello peeps", GetText(div), "Should be the peeps message");
OpenLinkerWindow(ed2);
IList<HtmlForm> sections = GetFormOfImageManagerTopSection(); // custom dialog has two frames
Assert.IsNotNull(sections, "Did not find form");
Assert.AreEqual(2, sections.Count, "Should be 2 elements");
// find a anchor link and click it
HtmlFindExpression findAnchors = new HtmlFindExpression();
findAnchors.AddClause("TagName=A");
ReadOnlyCollection<Element> expression = sections[1].Find.AllByExpression(findAnchors);
IEnumerable<HtmlAnchor> enumerable = expression.Select(a => new HtmlAnchor(a));
foreach (HtmlAnchor anchor in enumerable)
{
if (!anchor.InnerText.Contains("jesse"))
continue;
anchor.Click();
break;
}
sections = GetFormOfImageManagerTopSection();
var findButtons = new HtmlFindExpression();
findButtons.AddClause("TagName=input");
findButtons.AddClause("type=submit");
findButtons.AddClause("value=~Insert");
var insertButton = new HtmlInputSubmit(sections[0].Find.ByExpression(findButtons));
insertButton.Click(); // this button click closes the custom dialog
Thread.Sleep(4000); // just checking that it was not a timing issue
// this is the button click that does not work in this test.
Click(button); // I tried fetching the button at this point in the code but that didn't work either
div = GetOutputDiv();
Assert.AreEqual("Expected Text", GetText(div), "Editor text wrong");
}
0
Vyrban
Top achievements
Rank 1
answered on 22 Oct 2009, 07:23 AM
Hi woaksie
,
I my previous post i meant have U used RadFormDecorator - Telerik control that decorates the elements of the page in different Telerik skins.
U can see how it works here: http://demos.telerik.com/aspnet-ajax/formdecorator/examples/default/defaultcs.aspx .
As U can see in the this online demo, if U try to find the submit button in DOM, the button is represented as child of anchor. If U switch off decoration, the button is no more child of this anchor.
So when the button is not decorated the click can be performed on it, but when U decorate it, I think, the click can not be longer performed on the button, but on its parent - the anchor. but in your code i don't see any decorated action, so may be the reason for this malfunction i something else.
I my previous post i meant have U used RadFormDecorator - Telerik control that decorates the elements of the page in different Telerik skins.
U can see how it works here: http://demos.telerik.com/aspnet-ajax/formdecorator/examples/default/defaultcs.aspx .
As U can see in the this online demo, if U try to find the submit button in DOM, the button is represented as child of anchor. If U switch off decoration, the button is no more child of this anchor.
So when the button is not decorated the click can be performed on it, but when U decorate it, I think, the click can not be longer performed on the button, but on its parent - the anchor. but in your code i don't see any decorated action, so may be the reason for this malfunction i something else.
0
Hi,
We were able to reproduce the issue. The problem is due to that when the RadEditor custom dialog appears on the page then it is added as a first child of the HtmlForm. Then it changes the absolute indexes of the elements in the DOM and you cannot click it on a second try.
What you have to do is to refresh the button just before pressing it. ( button.Refresh() )
If this does not help, please contact us for further assistance.
All the best,
Petko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
We were able to reproduce the issue. The problem is due to that when the RadEditor custom dialog appears on the page then it is added as a first child of the HtmlForm. Then it changes the absolute indexes of the elements in the DOM and you cannot click it on a second try.
What you have to do is to refresh the button just before pressing it. ( button.Refresh() )
If this does not help, please contact us for further assistance.
All the best,
Petko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
woaksie
Top achievements
Rank 2
answered on 22 Oct 2009, 08:30 PM
I have it working now. The button and div I am trying to locate are actually off the visible page. I added ActiveBrowser.ScrollBy(0,10000) to scroll to the bottom and now the test works. I added this just before I find and click the button and before I find and read the div.
I did add the button refresh but it works with or without this now.
I also added a ActiveBrowser.WaitUntilReady() after the button click because I would sometimes get
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
on the following ScrollBy call.
Thanks for the help.
I did add the button refresh but it works with or without this now.
I also added a ActiveBrowser.WaitUntilReady() after the button click because I would sometimes get
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
on the following ScrollBy call.
Thanks for the help.