Search code examples
c#watin

Navigate with WatiN


I try to automate a Task "Navigating on a Website" with WatiN. Now, I have the following problem:

The website shows this:

enter image description here

There I have to simulate a click on "Einstellungen". When I look at the Sourcecode it looks like:

        <div class="ui-widget ui-opt-outer-nav ui-widget-content ui-corner-all nav_nav_panel">  
            <div class="ui-widget ui-opt-inner-nav ui-widget-content ui-corner-all">            
                <div id="NAV" class="nav_nav nav_pointer">
                    <ul>
                        <li id="jBtnMENUShipmentList"       data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0120">Sendungsübersicht</label></span></span></li>
                        <li id="jBtnMENUCreateShipment"     data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0130">Sendung erstellen</label></span></span></li>
                        <li id="jBtnMENUAddressBook"        data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0140">Adressbuch</label></span></span></li>
                        <li id="jBtnMENUEndOfDayManifest"   data-opt-load-type="menu">
                            <span class="select-buttons" data-opt-title="">
                                <span><label data-opt-label-key="V7GMGLMBTN0150">Tagesabschluss</label></span>
                            </span>
                        </li>
                        <li id="jBtnMENUPickup"         data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0160">Abholung</label></span></span></li>
                        <li id="jBtnMENURateEnquiry"        data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0170">Preisauskunft</label></span></span></li>
                        <li id="jBtnMENUExpertFunctions"    data-opt-load-type="link"><span><span><label data-opt-label-key="V7GMGLMBTN0180">Einstellungen</label></span></span></li>
                    </ul>
            </div>
        </div>
    </div>

But I have no idea, how I can now with WatiN simulate the click on "Einstellungen".

I have tried:

browser.Link(Find.ByName("jBtnMENUExpertFunctions")).Click();

but with no success.


Solution

  • Comment from jessehouwing is the solution:

    The Browser.Link method will search for a Link element, but the element in the DOM you need to click is a Label, so you should probably use:

    Browser.Label(Find.ByText("Einstellungen").Click()