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

firing OnClick event for IE

3 Answers 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 28 Oct 2015, 07:51 PM

I was originally working with chrome, but I changed over to IE b/c I needed the Image validation Tools(they're not in chrome).

I had already made most of my tests and they were working just fine BUT when I started running them in IE I found my tests that try to fire an anchor onClick didn't work and I tried again in chrome to make sure and they still work there. This is my method I made...

public void Room_Booking_CodedStep1()
{   
    String title = "title="+DateTime.Now.AddDays(1).ToString("MMMM") + " " + date.Day; // to alwasy be one day ahead EX "October 29"
    Element ele = Find.ByAttributes(title);
    var anchor = new HtmlAnchor(ele);
    anchor.InvokeEvent(ScriptEventType.OnClick);          
}

 the mark up i'm trying to call and i checked that they are the same in both browsers

<a title="October 29" style="color: black;" href="javascript:__doPostBack('ctl00$ctl00$cphBaseMasterBody$cphAuthenticatedRightColumn$QuickBook1$calView','5780')">29</a>

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 29 Oct 2015, 03:07 PM
Hello,

Please try using .Click() instead, like this:
HtmlAnchor anchor = ActiveBrowser.Find.ByAttributes<HtmlAnchor>("title=" + DateTime.Now.AddDays(1).ToString("MMMM d")); // to always be one day ahead EX "October 29"
anchor.Click();

Notice I also optimized the code at the same time.


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
John
Top achievements
Rank 1
answered on 29 Oct 2015, 03:27 PM

thanks a ton, I didn't know about "ActiveBrowser" and now my test are running so much better.

I'm using the test studio code viewer to do my coding, I was wounding if you would recommend using the Visual studio ?

 

0
Cody
Telerik team
answered on 29 Oct 2015, 05:09 PM
Hi John,

I'm glad I could help! Personally I'm used to using the complex Visual Studio IDE and I do prefer using it when I'm dealing with code. It's intellisense is smarter than the one built into Test Studio IDE. For everything else I do use the Test Studio IDE.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Cody
Telerik team
John
Top achievements
Rank 1
Share this question
or