Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

KarafIntegrationIT.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2000-2017 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * 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, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.test.osgi;
  17. import static org.junit.Assert.assertEquals;
  18. import org.junit.After;
  19. import org.junit.Before;
  20. import org.junit.Test;
  21. import org.openqa.selenium.By;
  22. import org.openqa.selenium.WebDriver;
  23. import org.openqa.selenium.WebElement;
  24. import org.openqa.selenium.phantomjs.PhantomJSDriver;
  25. import org.openqa.selenium.support.ui.WebDriverWait;
  26. import com.google.common.base.Predicate;
  27. import com.vaadin.testbench.TestBenchTestCase;
  28. import com.vaadin.testbench.elements.TextFieldElement;
  29. public class KarafIntegrationIT extends TestBenchTestCase {
  30. private static final String URL_PREFIX = "http://localhost:8181/";
  31. private static final String APP1_URL = URL_PREFIX + "myapp1";
  32. private static final String APP2_URL = URL_PREFIX + "myapp2";
  33. @Test
  34. public void testApp1() {
  35. runBasicTest(APP1_URL, "bar");
  36. // App theme should make a button pink
  37. WebElement element = getDriver().findElement(By.className("v-button"));
  38. String buttonColor = element.getCssValue("color");
  39. assertEquals("rgba(255, 128, 128, 1)", buttonColor);
  40. }
  41. @Test
  42. public void testApp2() {
  43. runBasicTest(APP2_URL, "foo");
  44. }
  45. private void runBasicTest(String app1Url, String text) {
  46. getDriver().navigate().to(app1Url);
  47. Predicate<WebDriver> isTrue = driver -> isElementPresent(
  48. TextFieldElement.class);
  49. new WebDriverWait(getDriver(), 5000).until(isTrue);
  50. getDriver().findElement(By.className("v-textfield")).sendKeys(text);
  51. getDriver().findElement(By.className("v-button")).click();
  52. String foundText = getDriver().findElement(By.className("v-label"))
  53. .getText();
  54. assertEquals("Thanks " + text + ", it works!", foundText);
  55. }
  56. @Before
  57. public void setup() {
  58. setDriver(new PhantomJSDriver());
  59. }
  60. @After
  61. public void teardown() {
  62. getDriver().quit();
  63. }
  64. }