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.

SubWindowsTextSelectionTest.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.window;
  17. import java.util.List;
  18. import org.junit.Assert;
  19. import org.junit.Test;
  20. import org.openqa.selenium.By;
  21. import org.openqa.selenium.JavascriptExecutor;
  22. import org.openqa.selenium.Point;
  23. import org.openqa.selenium.WebElement;
  24. import org.openqa.selenium.interactions.Actions;
  25. import org.openqa.selenium.remote.DesiredCapabilities;
  26. import com.vaadin.testbench.parallel.Browser;
  27. import com.vaadin.tests.tb3.MultiBrowserTest;
  28. /**
  29. * Test for issue #12726, IE's make text selection when sub windows are
  30. * dragged(moved).
  31. *
  32. * @since
  33. * @author Vaadin Ltd
  34. */
  35. public class SubWindowsTextSelectionTest extends MultiBrowserTest {
  36. /*
  37. * (non-Javadoc)
  38. *
  39. * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass()
  40. */
  41. @Override
  42. protected Class<?> getUIClass() {
  43. return SubWindows.class;
  44. }
  45. @Override
  46. public List<DesiredCapabilities> getBrowsersToTest() {
  47. return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11);
  48. }
  49. @Test
  50. public void verifyNoTextSelectionOnMove() throws Exception {
  51. openTestURL();
  52. WebElement element = driver.findElement(By
  53. .className("v-window-outerheader"));
  54. Point location = element.getLocation();
  55. element.click();
  56. new Actions(driver).moveToElement(element).perform();
  57. sleep(100);
  58. // move pointer bit right from the caption text
  59. new Actions(driver).moveByOffset(50, 0).clickAndHold()
  60. .moveByOffset(10, 2).moveByOffset(10, 0).moveByOffset(10, 0)
  61. .moveByOffset(10, 0).release().perform();
  62. String selection = ((JavascriptExecutor) getDriver()).executeScript(
  63. "return document.getSelection().toString();").toString();
  64. Assert.assertTrue("Text selection was not empty:" + selection,
  65. selection.isEmpty());
  66. // Verify also that window was really moved
  67. Point location2 = element.getLocation();
  68. Assert.assertEquals(location.getX() + (4 * 10), location2.getX());
  69. }
  70. }