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

Telerik testing Framework - Anchor Click method not working with IE

8 Answers 183 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Julio
Top achievements
Rank 1
Julio asked on 21 Sep 2012, 10:27 PM
Hi Guys

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

Sort by
0
Cody
Telerik team
answered on 24 Sep 2012, 10:13 PM
Hi Julio,

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.

Regards,
Cody
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
Julio
Top achievements
Rank 1
answered on 28 Sep 2012, 05:11 PM
Thanks Cody

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
0
Cody
Telerik team
answered on 01 Oct 2012, 05:53 PM
Hello 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.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Julio
Top achievements
Rank 1
answered on 01 Oct 2012, 08:15 PM
Thanks Cody

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


0
Cody
Telerik team
answered on 01 Oct 2012, 10:53 PM
Hi Julio,

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.

Kind regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Julio
Top achievements
Rank 1
answered on 02 Oct 2012, 03:07 PM
Hi Cody
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
0
Accepted
Cody
Telerik team
answered on 03 Oct 2012, 09:23 PM
Hi Julio,

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
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Julio
Top achievements
Rank 1
answered on 03 Oct 2012, 09:41 PM
Thanks Cody for taking a deeper look at this
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.
Tags
General Discussions
Asked by
Julio
Top achievements
Rank 1
Answers by
Cody
Telerik team
Julio
Top achievements
Rank 1
Share this question
or