Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have jsf portlet in liferay I have written a selenium test the test is getting passed but the submit button is not working below code:

Selenium code

 this.driver.get(this.baseUrl);
        this.login();
        this.driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        this.findElementById("category_items").sendKeys("Aplication Complaint");
        System.out.println("----clicked---");
        this.findElementById("subject_items").sendKeys("test");

        this.findElementById("description").sendKeys("ATFDC.Application.Complaint");
        this.findElementById("affected_assets").sendKeys("LDA 13");
        this.findElementById("calendar_date_occured").sendKeys("2013/08/04 19:07");
        this.findElementById("severity_list").sendKeys("All sites down");
        this.findElementById("submit_button").click();
        this.waitUntilAjaxRequestCompletes();
        System.out.println("submit clicked");

XHTML code snippet:

        <h:panelGroup id="severity_panel_group" styleClass="atf-form-line" layout="block"
            rendered="#{createTicketBaseBean.selectMenus.renderSeverityMenu}"
            style= "#{createTicketBaseBean.selectMenus.showSeverityMenu ? '' : 'display:none'}">
            <atf:selectOneInput componentId="severity_list"
                labelText="#{I18N['key_label_severity']}"
                tooltipText="#{I18N['key_tooltip_severity']}"
                value="#{createTicketBaseBean.ticketModel.severity}">
                <f:selectItems value="#{createTicketBaseBean.selectMenus.severityItems}" />
            </atf:selectOneInput>
        </h:panelGroup>

            <h:panelGroup id="panel_separator" layout="block" styleClass="atf-inline-block atf-w25p atf-vertical-align-top">
                <h:outputText value="#{I18N['key_value_mandatory']}" styleClass="atf-text-not-required" />
            </h:panelGroup>
            <h:panelGroup id="panel_commands" layout="block" styleClass="atf-inline-block atf-w70p">
                <p:commandButton value="#{I18N['key_button_submit_ticket']}"
                    title="#{I18N['key_button_submit_ticket']}" actionListener="#{createTicketBaseBean.createTicketData}"
                    action="#{createTicketBaseBean.createTicket}"
                    styleClass="atf-right" process="@form" update="@form" id="submit_button">
                </p:commandButton>

                <p:commandButton value="#{I18N['key_button_clear']}"
                    title="#{I18N['key_button_clear']}"
                    actionListener="#{createTicketBaseBean.clearProperties}"
                    styleClass="atf-left" global="true"  process="@this" update="@form" immediate="true">
                </p:commandButton>
            </h:panelGroup>
        </h:panelGroup>

The output prints submit clicked

share|improve this question
What is supposed to happen when the button is pressed, and what actually happens? – vincebowdren yesterday
What should happen-->Soap request should be sent but its not sent. – sidkool3k yesterday
add comment (requires an account with 50 reputation)

1 Answer

You have to find a tag that appears after clicking on the submit button. You have to wait till that tag appears.

public boolean waitForElement(WebElement ele, String xpath, int seconds) throws InterruptedException{
    //returns true if the xpath appears in the webElement within the time
    //false when timed out
    int t=0;
    while(t<seconds*10){
        if(ele.findElements(By.xpath(xpath)).size()>0)
            return true;
        else{
            Thread.sleep(100);
            t++;
            continue;
        }
    }       
    System.out.println("waited for "+seconds+"seconds. But couldn't find "+xpath+ " in the element specified");
    return false;
}
share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.