/*
 * Copyright (C) 2012 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.auraframework.components.aura.model;

import java.util.List;

import org.auraframework.test.WebDriverTestCase;
import org.auraframework.test.annotation.UnAdaptableTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

/**
 * aura:interation UI tests.
 * 
 * 
 * @since 0.0.256
 */
public class AuraModelExceptionUITest extends WebDriverTestCase {

    public AuraModelExceptionUITest(String name) {
        super(name);
    }

    @UnAdaptableTest
    public void testRendererException() throws Exception {
        openNoAura("/auratest/testModelThatThrowsInRenderer.cmp");
        waitForDocumentReady();
        List<WebElement> errorBoxes = getDriver().findElements(By.cssSelector(".auraForcedErrorBox"));
        assertEquals("Element not found", 1, errorBoxes.size());
        assertTrue("Error not displayed", errorBoxes.get(0).isDisplayed());
    }

    public void testModelSerializationException() throws Exception {
        openNoAura("/auratest/testModelThatThrows.cmp");
        waitForDocumentReady();
        List<WebElement> errorBoxes = getDriver().findElements(By.cssSelector(".auraForcedErrorBox"));
        assertEquals("Renderer element found", 0, errorBoxes.size());
        errorBoxes = getDriver().findElements(By.cssSelector(".auraErrorBox"));
        assertEquals("Element not found", 1, errorBoxes.size());
        assertTrue(errorBoxes.get(0).isDisplayed());
    }
}

@@ -847,22 +847,170 @@
 nium.Web
-Elemen
+Driver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.support.ui.ExpectedCondition;%0Aimport org.openqa.selenium.support.ui.WebDriverWai
 t;%0A%0A/**%0A
@@ -1987,142 +1987,509 @@
     
-errorBoxes = getDriver().findElements(By.cssSelector(%22.auraErrorBox%22));%0A        assertEquals(%22Element not found%22, 1, errorBoxes.size()
+WebDriverWait wait = new WebDriverWait(getDriver(), timeoutInSecs);%0A        errorBoxes = wait.until(new ExpectedCondition%3CList%3CWebElement%3E%3E() %7B%0A            @Override%0A            public List%3CWebElement%3E apply(WebDriver d) %7B%0A                List%3CWebElement%3E errors = getDriver().findElements(By.cssSelector(%22.auraErrorBox%22));%0A                if (errors.size() %3E 0 && errors.get(0).isDisplayed()) %7B%0A                    return errors;%0A                %7D%0A                return null;%0A            %7D%0A        %7D
 );%0A 
@@ -2501,20 +2501,23 @@
   assert
-True
+NotNull
 (errorBo
@@ -2519,37 +2519,16 @@
 rorBoxes
-.get(0).isDisplayed()
 );%0A    %7D

fix flapper for AuraModelExceptionUITest Description: