firing OnClick event for IE

4 posts, 0 answers
  1. John
    John avatar
    12 posts
    Member since:
    Oct 2015

    Posted 28 Oct 2015 Link to this post

    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>

  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 29 Oct 2015 Link to this post

    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!
  3. John
    John avatar
    12 posts
    Member since:
    Oct 2015

    Posted 29 Oct 2015 in reply to Cody Link to this post

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

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

     

  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 29 Oct 2015 Link to this post

    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!
Back to Top