You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KarafIntegrationIT.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 com.vaadin.testbench.TestBenchTestCase;
  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.WebElement;
  23. import org.openqa.selenium.phantomjs.PhantomJSDriver;
  24. import static org.junit.Assert.assertEquals;
  25. public class KarafIntegrationIT extends TestBenchTestCase {
  26. private static final String URL_PREFIX = "http://localhost:8181/";
  27. private static final String APP1_URL = URL_PREFIX + "myapp1";
  28. private static final String APP2_URL = URL_PREFIX + "myapp2";
  29. @Test
  30. public void testApp1() {
  31. runBasicTest(APP1_URL, "bar");
  32. //App theme should make a button pink
  33. WebElement element = getDriver().findElement(By.className("v-button"));
  34. String buttonColor = element.getCssValue("color");
  35. assertEquals("rgba(255, 128, 128, 1)", buttonColor);
  36. }
  37. @Test
  38. public void testApp2() {
  39. runBasicTest(APP2_URL, "foo");
  40. }
  41. private void runBasicTest(String app1Url, String text) {
  42. getDriver().navigate().to(app1Url);
  43. getDriver().findElement(By.className("v-textfield")).sendKeys(text);
  44. getDriver().findElement(By.className("v-button")).click();
  45. String foundText = getDriver().findElement(By.className("v-label")).getText();
  46. assertEquals("Thanks " + text + ", it works!", foundText);
  47. }
  48. @Before
  49. public void setup() {
  50. setDriver(new PhantomJSDriver());
  51. }
  52. @After
  53. public void teardown() {
  54. getDriver().quit();
  55. }
  56. }