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.

ComboboxMenuBarAutoopenTest.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 org.junit.Assert;
  18. import org.junit.Test;
  19. import org.openqa.selenium.By;
  20. import org.openqa.selenium.WebElement;
  21. import org.openqa.selenium.interactions.Actions;
  22. import com.vaadin.testbench.elements.ComboBoxElement;
  23. import com.vaadin.testbench.elements.MenuBarElement;
  24. import com.vaadin.tests.tb3.MultiBrowserTest;
  25. /**
  26. * Test that checks whether Combobox popup is closed on click to autoopen
  27. * menubar and its item.
  28. *
  29. * @author Vaadin Ltd
  30. */
  31. public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest {
  32. @Test
  33. public void closeComboboxPopupOnClickToMenuBar() {
  34. openTestURL();
  35. openPopup();
  36. MenuBarElement menuBar = selectMenuBar();
  37. menuBar.click();
  38. Assert.assertFalse("Combobox popup items are visible",
  39. isElementPresent(By.className("gwt-MenuItem")));
  40. openPopup();
  41. menuBar = selectMenuBar();
  42. WebElement menuBarItem = findElement(By
  43. .className("v-menubar-menuitem-caption"));
  44. Actions actions = new Actions(getDriver());
  45. actions.moveToElement(menuBarItem).build().perform();
  46. menuBar.click();
  47. Assert.assertFalse("Combobox popup items are visible",
  48. isElementPresent(By.className("gwt-MenuItem")));
  49. }
  50. private void openPopup() {
  51. ComboBoxElement combobox = $(ComboBoxElement.class).first();
  52. combobox.click();
  53. combobox.openPopup();
  54. combobox.focus();
  55. Actions actions = new Actions(getDriver());
  56. actions.moveToElement(
  57. getDriver().findElement(By.className("gwt-MenuItem"))).build()
  58. .perform();
  59. }
  60. private MenuBarElement selectMenuBar() {
  61. MenuBarElement menuBar = $(MenuBarElement.class).first();
  62. menuBar.focus();
  63. Actions actions = new Actions(getDriver());
  64. actions.moveToElement(menuBar).build().perform();
  65. return menuBar;
  66. }
  67. }