I'm using the Telerik Testing Framework (C#) and implementing the Telerik libraries, but there is a problem executing the Click method of an Anchor that is inside of a Span, this problem only presents with IE browser, instead of Click i need to do a MouseClick action.
This behavior only presents over one specific object of the application tested, in other anchor I don't have to deal with that problem, also noticed that with Firefox and Chrome the Click method works perfectly okay.
MouseClick works but is not the ideal way because we have a dependency of the mouse action and the focus/display on the application, I mean MouseClick don't work for Continuous Integration
if (myManager.ActiveBrowser.BrowserType != BrowserType.InternetExplorer)
{
myManager.ActiveBrowser.Find.ByExpression<HtmlAnchor>("href=#", "innerText=" + GetLangInfo("Name")).Click();
}
else
myManager.ActiveBrowser.Find.ByExpression<HtmlAnchor>("href=#", "innerText=" + GetLangInfo("Name")).MouseClick();
Any help would be really appreciated
Julio Cesar
8 Answers, 1 is accepted
I cannot determine why the .Click in IE isn't working as expected. I need to be able to reproduce the problem on my local machine so I investigate what is going on.
Here's another approach you could consider taking: since a click on a hyperlink generally causes the browser to navigate to a different URL, you could replace the click with:
myManager.ActiveBrowser.NavigateTo("new URL here");
This should work in all browsers and bypass the extra click.
Cody
the Telerik team
Vote now
The problem is that I cannot use the "NavigateTo" method because is not going to another URL, is a navigation under the same URL (Developers are using a href=# to specify that is on the same URL the functionality)
Please keep me posted if you find anything weird on your side using IE and Anchor.Click method
Thanks
Julio
Technically the following URL examples are different URL's and you can use NavigateTo to get to them:
http://myserver.com/myappPath/myappPage.aspx/?query1=abc
http://myserver.com/myappPath/myappPage.aspx/?query1=abc#loc1
http://myserver.com/myappPath/myappPage.aspx/?query1=abc#loc2
The href of the hyperlink may only contain "#loc1" but that is still translated by the web browser into a full and complete URL which the browser then sends a request to the web server to obtain. So in the end yes you still can use NavigateTo for a fragment identifier.
Please keep me posted if you find anything weird on your side using IE and Anchor.Click method
Can you give me a public URL I can access to reproduce this symptom? Then I'd be very happy to investigate the cause.
Cody
the Telerik team
Test Studio Trainings
I couldn't access the URL's you gave me, BUT I will give a try with this approach, thanks
Sure, here is the URL where you can play with and see more clearly what my problem is:
https://vmp-euwebapp-001.alldata.com/alldata/user/login/
You don't need to login, the fail is presenting when clicking the Span (Language Selector) (Located on the Top-Right corner),
Remember I'm having the issue with IE only
Here is the code used,
myManager.ActiveBrowser.Window.SetFocus();
myManager.ActiveBrowser.Find.ByContent<HtmlSpan>("Deutsch").Click();
if (myManager.ActiveBrowser.BrowserType != BrowserType.InternetExplorer)
{
myManager.ActiveBrowser.Find.ByExpression<HtmlAnchor>("href=#", "innerText="English").Click();
}
else
myManager.ActiveBrowser.Find.ByExpression<HtmlAnchor>("href=#", "innerText="English").MouseClick();
Any other thing just let me know
The URL's in my last message are not real URL's. They were meant to demonstrate the pattern. They will not take you to a real website.
I am not able to connect to that URL. The name will not resolve - see attached screen shot. Else I'd be happy to look into this.
Cody
the Telerik team
Test Studio Trainings
Please try with this one:
https://app.alldata.com/alldata/user/login/
This should work for you
Please keep me posted if you find anything
Thanks
I found out a couple of key things about your application:
1) It's using jQuery events. Test Studio generally doesn't activate these events.
2) Your application is changing which jQuery event gets attached depends on which browser is being used. This is clearly demonstrated in the first two attached screen shots.
I came up with a different solution that works across browsers, but because of the variable event in IE we still have to have an IF just to handle that case:
if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer)
{
Actions.InvokeScript("$('#en_GB a').mousedown()");
}
else
{
Actions.InvokeScript("$('#en_GB a').click()");
}
To change to one of the other languages replace en_GB with the other desired ID (see last attached screen shot). Kind regards,
Cody
the Telerik team
Test Studio Trainings
Now I can see why the difference
I appreciate your help to clarify that this is not a Telerik's bug
I'll do a workaround to handle this behavior.