|
| 1 | +/* |
| 2 | + * Copyright 2014 eXo Platform SAS |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.juzu.tutorial; |
| 18 | + |
| 19 | +import juzu.test.AbstractWebTestCase; |
| 20 | + |
| 21 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 22 | +import org.jboss.arquillian.drone.api.annotation.Drone; |
| 23 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 24 | +import org.junit.Test; |
| 25 | +import org.openqa.selenium.By; |
| 26 | +import org.openqa.selenium.WebDriver; |
| 27 | +import org.openqa.selenium.WebElement; |
| 28 | +import org.openqa.selenium.support.ui.ExpectedCondition; |
| 29 | +import org.openqa.selenium.support.ui.WebDriverWait; |
| 30 | + |
| 31 | +public class Step2TestCase extends AbstractWebTestCase { |
| 32 | + |
| 33 | + @Deployment(testable = false) |
| 34 | + public static WebArchive createDeployment() { |
| 35 | + return createPortletDeployment("org.juzu.tutorial"); |
| 36 | + } |
| 37 | + |
| 38 | + @Drone |
| 39 | + WebDriver driver; |
| 40 | + |
| 41 | + @Test |
| 42 | + public void testAddSecret() throws Exception { |
| 43 | + driver.get(getPortletURL().toString()); |
| 44 | + WebElement body = driver.findElement(By.tagName("body")); |
| 45 | + assertFalse(body.getText().contains("test secret text")); |
| 46 | + |
| 47 | + //add secret form |
| 48 | + WebElement shareBtn = driver.findElement(By.tagName("a")); |
| 49 | + driver.get(shareBtn.getAttribute("href")); |
| 50 | + //input |
| 51 | + WebElement secretInput = driver.findElement(By.tagName("textarea")); |
| 52 | + secretInput.sendKeys("test secret text"); |
| 53 | + //submit |
| 54 | + WebElement submitBtn = driver.findElement(By.tagName("button")); |
| 55 | + submitBtn.submit(); |
| 56 | + |
| 57 | + //wait for redirecting to index page |
| 58 | + body = new WebDriverWait(driver, 10).until(new ExpectedCondition<WebElement>() { |
| 59 | + public WebElement apply(WebDriver drv) { |
| 60 | + return drv.findElement(By.tagName("body")); |
| 61 | + } |
| 62 | + }); |
| 63 | + System.out.println(body.getText()); |
| 64 | + assertTrue(body.getText().contains("test secret text")); |
| 65 | + } |
| 66 | +} |
0 commit comments