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.

ComboBoxSetNullWhenNewItemsAllowedTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2000-2014 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.tests.components.combobox;
  17. import static org.junit.Assert.assertEquals;
  18. import org.junit.Test;
  19. import org.openqa.selenium.Keys;
  20. import org.openqa.selenium.WebElement;
  21. import org.openqa.selenium.interactions.Actions;
  22. import com.vaadin.testbench.By;
  23. import com.vaadin.testbench.commands.TestBenchElementCommands;
  24. import com.vaadin.testbench.elements.ComboBoxElement;
  25. import com.vaadin.testbench.parallel.BrowserUtil;
  26. import com.vaadin.tests.tb3.MultiBrowserTest;
  27. /**
  28. * ComboBox should clear its value when setting to null with new items.
  29. */
  30. public class ComboBoxSetNullWhenNewItemsAllowedTest extends MultiBrowserTest {
  31. @Test
  32. public void testNewValueIsClearedAppropriately()
  33. throws InterruptedException {
  34. setDebug(true);
  35. openTestURL();
  36. WebElement element = $(ComboBoxElement.class).first().findElement(
  37. By.vaadin("#textbox"));
  38. ((TestBenchElementCommands) element).click(8, 7);
  39. element.clear();
  40. element.sendKeys("New value");
  41. assertEquals("New value", element.getAttribute("value"));
  42. if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
  43. new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
  44. Thread.sleep(500);
  45. } else {
  46. element.sendKeys(Keys.RETURN);
  47. }
  48. assertEquals("", element.getAttribute("value"));
  49. }
  50. }