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.

TreeScrollingOnRightClickTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2000-2016 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.v7.tests.components.tree;
  17. import static org.junit.Assert.assertEquals;
  18. import org.junit.Test;
  19. import org.openqa.selenium.By;
  20. import org.openqa.selenium.Keys;
  21. import org.openqa.selenium.Point;
  22. import org.openqa.selenium.WebElement;
  23. import org.openqa.selenium.interactions.Actions;
  24. import com.vaadin.tests.tb3.MultiBrowserTest;
  25. /**
  26. *
  27. * @since 7.1.9
  28. * @author Vaadin Ltd
  29. */
  30. public class TreeScrollingOnRightClickTest extends MultiBrowserTest {
  31. @Test
  32. public void testScrollingOnRightClick() throws Throwable {
  33. openTestURL();
  34. // Focus tree
  35. WebElement tree = getDriver()
  36. .findElement(By.id(TreeScrollingOnRightClick.TREE_ID));
  37. tree.click();
  38. // Move selection down 50 items
  39. for (int down = 0; down < 50; down++) {
  40. tree.sendKeys(Keys.ARROW_DOWN);
  41. }
  42. Thread.sleep(1000);
  43. // Get location of item 40
  44. Point item40Location = getTreeNode("Node 40").getLocation();
  45. // Right click on item 45
  46. WebElement item45 = getTreeNode("Node 45");
  47. new Actions(getDriver()).moveToElement(item45).contextClick(item45)
  48. .perform();
  49. // Ensure location of item 40 is still the same (no scrolling)
  50. Point item40Location2 = getTreeNode("Node 40").getLocation();
  51. assertEquals(item40Location.getY(), item40Location2.getY());
  52. }
  53. private WebElement getTreeNode(String caption) {
  54. return getDriver()
  55. .findElement(By.xpath("//span[text() = '" + caption + "']"));
  56. }
  57. }