/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.mail.test.po;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.xwiki.administration.test.po.AdministrationSectionPage;

/**
 * Represents the actions possible on the General Mail Administration Page.
 * 
 * @version $Id$
 * @since 6.4RC1
 */
public class SendMailAdministrationSectionPage extends AdministrationSectionPage
{
    @FindBy(id = "Mail.SendMailConfigClass_0_host")
    private WebElement host;

    @FindBy(id = "Mail.SendMailConfigClass_0_port")
    private WebElement port;

    @FindBy(id = "Mail.SendMailConfigClass_0_sendWaitTime")
    private WebElement sendWaitTime;

    @FindBy(id = "Mail.SendMailConfigClass_0_discardSuccessStatuses")
    private WebElement discardSuccessStatuses;

    public SendMailAdministrationSectionPage()
    {
        super("Mail Sending");
    }

    public String getHost()
    {
        return this.host.getAttribute("value");
    }

    public void setHost(String host)
    {
        this.host.clear();
        this.host.sendKeys(host);
    }

    public String getPort()
    {
        return this.port.getAttribute("value");
    }

    public void setPort(String port)
    {
        this.port.clear();
        this.port.sendKeys(port);
    }

    public String getSendWaitTime()
    {
        return this.sendWaitTime.getAttribute("value");
    }

    public void setSendWaitTime(String sendWaitTime)
    {
        this.sendWaitTime.clear();
        this.sendWaitTime.sendKeys(sendWaitTime);
    }

    /**
     * @since 6.4.1
     */
    public void setDiscardSuccessStatuses(boolean discardSuccessStatuses)
    {
        if (getDiscardSuccessStatuses() != discardSuccessStatuses) {
            this.discardSuccessStatuses.click();
        }
    }

    /**
     * @since 6.4.1
     */
    public boolean getDiscardSuccessStatuses()
    {
        return this.discardSuccessStatuses.isSelected();
    }
}

@@ -1002,16 +1002,62 @@
 FindBy;%0A
+import org.openqa.selenium.support.ui.Select;%0A
 import o
@@ -2576,43 +2576,40 @@
     
-if (getDiscardSuccessStatuses() != 
+Select select = new Select(this.
 disc
@@ -2627,18 +2627,17 @@
 tatuses)
- %7B
+;
 %0A       
@@ -2637,25 +2637,38 @@
         
-    this.
+select.selectByValue((
 discardS
@@ -2685,27 +2685,23 @@
 uses
-.click();%0A        %7D
+) ? %221%22 : %220%22);
 %0A   
@@ -2804,24 +2804,37 @@
      return 
+!(new Select(
 this.discard
@@ -2852,20 +2852,68 @@
 uses
-.isSelected(
+).getFirstSelectedOption().getAttribute(%22value%22).equals(%220%22)
 );%0A 

Discard mail statuses for successful sends property is lost when saving the Send Mail Admin UI page