The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20130904

sahi - how to set a richfaces rich:inputNumberSpinner value and verify it got set correctly

i have the following form composed of a rich:calendar and 2 rich:inputNumberSpinner elements:

<a4j:form id="dateAndTimeSetterForm">
    <h:panelGrid id="dateAndTimeSetter" style="border:1px" columns="1">
        <h:panelGrid style="border:0px;width:100%;align:center" columns="1">
            <rich:calendar
                requiredMessage="#{msg['label.timeRequired']}"
                value="#{listTRQsDataModel.requestHandler.dateInEditPosition}"
                required="#{listTRQsDataModel.requestHandler.dateTimeMandatory}"
                locale="#{userMenuBean.userLocale}" direction="auto"
                id="dateSetterCal" popup="false" showInput="true"
                showApplyButton="false" datePattern="#{msg['calendar.datePattern']}" cellWidth="24px"
                cellHeight="22px" style="width:200px;align:center;">
                <a4j:support event="onchanged" ajaxSingle="true"
                    reRender="hourSpinner, minuteSpinner" />
            </rich:calendar>
        </h:panelGrid>
        <h:panelGrid style="border:0px;width:100%;align:center;"
            columns="2">
            <h:outputLabel style="align:right"
                value="#{msg['label.hour']}" />
            <h:outputLabel
                value="#{msg['label.minute']}" />
            <rich:inputNumberSpinner id="hourSpinner" minValue="0"
                style="align:right" maxValue="23" inputSize="2"
                value="#{listTRQsDataModel.requestHandler.hourForTimeInEditPosition}" />
            <rich:inputNumberSpinner id="minuteSpinner" minValue="0"
                maxValue="59" inputSize="2"
                value="#{listTRQsDataModel.requestHandler.minuteForTimeInEditPosition}" />

        </h:panelGrid>
        <h:panelGrid style="border:0px;align:center;" columns="1">
            <a4j:commandButton id="setTimeBtn" style="align:center"
                styleClass="regularbutton"
                action="#{listTRQsDataModel.requestHandler.saveDateInPosition}"
                oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('time_panel_trq')}.hide()"
                reRender="#{listTRQsDataModel.requestHandler.dateIdentInEditPosition}"
                value="#{msg['label.setTime']}" />
        </h:panelGrid>
    </h:panelGrid>
</a4j:form>

which looks like this in a browser:



the following sahi code ...
* opens this date+time setting modal panel
* gets the current hour value (originally "12")
* clicks the "up arrow" icon for hour ("Time" in norwegian) to make the hour "13"
* verifies that the hour got set correctly
* then clicks the "set time" submit button ("Sett tid" in norwegian)
* then verifies that the modal panel is closed--the submit button is no longer visible

function set_trq_pickup_time_future_1_hr() {
    _click(_link("trq_det_form:setTimefirstpickupdate"));
 

    _wait(10000, _isVisible(_button("dateAndTimeSetterForm:setTimeBtn")));
 

    var $currentHour = _fetch(_textbox("dateAndTimeSetterForm:hourSpinner").value);
 

// clicks the first hour spinner based on class--there are two and "up 1 hour" is on top, i.e. first, so "down 1 hour" would be "rich-spinner-btn rich-spinner-button[1]"
    _click(_imageSubmitButton("rich-spinner-btn rich-spinner-button", _in(_table("dateAndTimeSetterForm:hourSpinnerButtons"))));
 

    var $newHour = ($currentHour+1);
 

    _wait(_textbox("dateAndTimeSetterForm:hourSpinner").value == $newHour);
 

    _click(_button("dateAndTimeSetterForm:setTimeBtn"));
 

    _wait(10000, _isVisible(_button("dateAndTimeSetterForm:setTimeBtn")) == false);
}

No comments:

Post a Comment