jeudi 2 juillet 2015

Hand coded C# Coded UI Test , Control/Object location issue

I'm a QTP tester, but now working with coded UI tests in Visual Studio 2013 because of my new job. I'm trying to write it all by hand as a way of learning c# in the process (and I also used to descriptively code in VbScript for QTP so this is my preferred method). As you can imagine I'm running into a few roadblocks because of the new environment.

I have a dropdown menu sub-item ("logout"!) that I cannot find a way/path to select because I need to hover over the menu first to make the logout link appear. This is one of those situations where there's a lot of div's surrounding it (the spy tells me it's an "HTMLPANE", but there's no built-in support for HtmlPanes in VS code as far as I can see (i.e I try typing it in and intellisense doesnt recognize it, not from htmlcontrols namesspace I guess) - so just before trying to describe this main menu object, I'm defining the variable as an HtmlDiv , I've even tried to identify it generically by referring to it as an HtmlControl, nothing works there?).

Here's the "view source" of the page (just the dropdown menu in question). I need to get to the good ol' "Logout" link which is the bottom option in the dropdown.

        <span class="icon-profile menu"></span>
        <span class="profile-header tablet-hide"> Profile</span>

        <div class="ma-menu-items left">
                <a id="nav-my-account-profile" href="/my-account/profile/">Edit Profile</a>
                <a id="nav-my-account-profile-view-card" href="/my-account/profile/view-card/">View ID Card</a>
                <a id="nav-my-account-profile-request-card" href="/my-account/profile/request-card/">Request ID Card</a>
                <a id="nav-my-account-profile-logoff" href="/my-account/profile/logoff/">Log Out</a>
        </div>
    </li>
</ul>

I'm not familiar with the mouse.hover function, or how to use it, so if you think that's what I need here, I've done a tonne of research with no results, can you please show me an actual example (preferably from this code)!!! I'm not even sure if this is a great way to identify it because from what I observed by recording the hover, browser resizing changes the coordinates. Regardless of that, my ignorance of mouse.hover means I dont even know if you are obliged to give a coordinate (new, point?? etc..??)--- Or, as I would prefer(!) are you able to just specify the name of the object control you want it to hover over, i.e. mouse.hover(varnameformainmenu);

I really appreciate your input and patience. Best, Yan.

Aucun commentaire:

Enregistrer un commentaire