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.

GridBasicClientFeaturesTest.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.grid.basicfeatures;
  17. import org.openqa.selenium.Dimension;
  18. import org.openqa.selenium.WebElement;
  19. import org.openqa.selenium.interactions.Actions;
  20. import com.vaadin.testbench.By;
  21. import com.vaadin.testbench.TestBenchElement;
  22. import com.vaadin.testbench.elements.GridElement;
  23. /**
  24. * GridBasicClientFeatures.
  25. *
  26. * @since
  27. * @author Vaadin Ltd
  28. */
  29. public abstract class GridBasicClientFeaturesTest extends GridBasicFeaturesTest {
  30. private boolean composite = false;
  31. @Override
  32. protected Class<?> getUIClass() {
  33. return GridBasicClientFeatures.class;
  34. }
  35. @Override
  36. protected String getDeploymentPath() {
  37. String path = super.getDeploymentPath();
  38. if (composite) {
  39. path += (path.contains("?") ? "&" : "?") + "composite";
  40. }
  41. return path;
  42. }
  43. protected void setUseComposite(boolean useComposite) {
  44. composite = useComposite;
  45. }
  46. @Override
  47. protected void selectMenu(String menuCaption) {
  48. WebElement menuElement = getMenuElement(menuCaption);
  49. Dimension size = menuElement.getSize();
  50. new Actions(getDriver()).moveToElement(menuElement, size.width - 10,
  51. size.height / 2).perform();
  52. }
  53. private WebElement getMenuElement(String menuCaption) {
  54. return getDriver().findElement(
  55. By.xpath("//td[text() = '" + menuCaption + "']"));
  56. }
  57. @Override
  58. protected void selectMenuPath(String... menuCaptions) {
  59. new Actions(getDriver()).moveToElement(getMenuElement(menuCaptions[0]))
  60. .click().perform();
  61. for (int i = 1; i < menuCaptions.length - 1; ++i) {
  62. selectMenu(menuCaptions[i]);
  63. new Actions(getDriver()).moveByOffset(20, 0).perform();
  64. }
  65. new Actions(getDriver())
  66. .moveToElement(
  67. getMenuElement(menuCaptions[menuCaptions.length - 1]))
  68. .click().perform();
  69. }
  70. @Override
  71. protected GridElement getGridElement() {
  72. if (composite) {
  73. // Composite requires the basic client features widget for subparts
  74. return ((TestBenchElement) findElement(By
  75. .vaadin("//TestWidgetComponent"))).wrap(GridElement.class);
  76. } else {
  77. return super.getGridElement();
  78. }
  79. }
  80. }