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.

MultiBrowserTest.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.tb3;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import org.openqa.selenium.ie.InternetExplorerDriver;
  20. import org.openqa.selenium.remote.DesiredCapabilities;
  21. import com.vaadin.testbench.parallel.Browser;
  22. import com.vaadin.testbench.parallel.BrowserUtil;
  23. /**
  24. * Base class for tests which should be run on all supported browsers. The test
  25. * is automatically launched for multiple browsers in parallel by the test
  26. * runner.
  27. *
  28. * Sub classes can, but typically should not, restrict the browsers used by
  29. * implementing a
  30. *
  31. * <pre>
  32. * &#064;Parameters
  33. * public static Collection&lt;DesiredCapabilities&gt; getBrowsersForTest() {
  34. * }
  35. * </pre>
  36. *
  37. * @author Vaadin Ltd
  38. */
  39. public abstract class MultiBrowserTest extends PrivateTB3Configuration {
  40. protected List<DesiredCapabilities> getBrowsersSupportingWebSocket() {
  41. // No WebSocket support in IE8-9 and PhantomJS
  42. return getBrowserCapabilities(Browser.IE10, Browser.IE11,
  43. Browser.FIREFOX, Browser.CHROME);
  44. }
  45. protected List<DesiredCapabilities> getBrowsersExcludingPhantomJS() {
  46. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  47. Browser.IE11, Browser.CHROME, Browser.FIREFOX);
  48. }
  49. protected List<DesiredCapabilities> getBrowsersExcludingIE() {
  50. return getBrowserCapabilities(Browser.FIREFOX, Browser.CHROME,
  51. Browser.PHANTOMJS);
  52. }
  53. protected List<DesiredCapabilities> getBrowsersExcludingIE8() {
  54. return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11,
  55. Browser.FIREFOX, Browser.CHROME, Browser.PHANTOMJS);
  56. }
  57. protected List<DesiredCapabilities> getBrowsersSupportingShiftClick() {
  58. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  59. Browser.IE11, Browser.CHROME);
  60. }
  61. protected List<DesiredCapabilities> getIEBrowsersOnly() {
  62. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  63. Browser.IE11);
  64. }
  65. @Override
  66. public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) {
  67. if (BrowserUtil.isIE(desiredCapabilities)) {
  68. if (requireWindowFocusForIE()) {
  69. desiredCapabilities.setCapability(
  70. InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
  71. }
  72. if (!usePersistentHoverForIE()) {
  73. desiredCapabilities.setCapability(
  74. InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING,
  75. false);
  76. }
  77. }
  78. super.setDesiredCapabilities(desiredCapabilities);
  79. }
  80. @Override
  81. public List<DesiredCapabilities> getBrowsersToTest() {
  82. // Uncomment Safari and Opera if those become tested browsers again.
  83. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  84. Browser.IE11, Browser.FIREFOX, Browser.CHROME,
  85. Browser.PHANTOMJS /* , Browser.SAFARI, Browser.OPERA */);
  86. }
  87. protected List<DesiredCapabilities> getBrowserCapabilities(
  88. Browser... browsers) {
  89. List<DesiredCapabilities> capabilities = new ArrayList<DesiredCapabilities>();
  90. for (Browser browser : browsers) {
  91. capabilities.add(browser.getDesiredCapabilities());
  92. }
  93. return capabilities;
  94. }
  95. }