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 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.remote.DesiredCapabilities;
  20. import com.vaadin.testbench.parallel.Browser;
  21. /**
  22. * Base class for tests which should be run on all supported browsers. The test
  23. * is automatically launched for multiple browsers in parallel by the test
  24. * runner.
  25. *
  26. * Sub classes can, but typically should not, restrict the browsers used by
  27. * implementing a
  28. *
  29. * <pre>
  30. * &#064;Parameters
  31. * public static Collection&lt;DesiredCapabilities&gt; getBrowsersForTest() {
  32. * }
  33. * </pre>
  34. *
  35. * @author Vaadin Ltd
  36. */
  37. public abstract class MultiBrowserTest extends PrivateTB3Configuration {
  38. protected List<DesiredCapabilities> getBrowsersSupportingWebSocket() {
  39. // No WebSocket support in IE8-9 and PhantomJS
  40. return getBrowserCapabilities(Browser.IE10, Browser.IE11,
  41. Browser.FIREFOX, Browser.CHROME);
  42. }
  43. protected List<DesiredCapabilities> getBrowsersExcludingPhantomJS() {
  44. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  45. Browser.IE11, Browser.CHROME, Browser.FIREFOX);
  46. }
  47. protected List<DesiredCapabilities> getBrowsersExcludingIE() {
  48. return getBrowserCapabilities(Browser.FIREFOX, Browser.CHROME,
  49. Browser.PHANTOMJS);
  50. }
  51. protected List<DesiredCapabilities> getBrowsersExcludingFirefox() {
  52. // this is sometimes needed as the Firefox driver causes extra mouseOut
  53. // events that make tooltips disappear etc.
  54. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  55. Browser.IE11, Browser.CHROME, Browser.PHANTOMJS);
  56. }
  57. protected List<DesiredCapabilities> getBrowsersExcludingIE8() {
  58. return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11,
  59. Browser.FIREFOX, Browser.CHROME, Browser.PHANTOMJS);
  60. }
  61. protected List<DesiredCapabilities> getBrowsersSupportingShiftClick() {
  62. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  63. Browser.IE11, Browser.CHROME);
  64. }
  65. protected List<DesiredCapabilities> getIEBrowsersOnly() {
  66. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  67. Browser.IE11);
  68. }
  69. protected List<DesiredCapabilities> getBrowsersSupportingContextMenu() {
  70. // context menu doesn't work in phantom JS and works weirdly with IE8
  71. // and selenium.
  72. return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11,
  73. Browser.FIREFOX, Browser.CHROME);
  74. }
  75. protected List<DesiredCapabilities> getBrowsersSupportingTooltip() {
  76. // With IEDriver, the cursor seems to jump to default position after the
  77. // mouse move, so we are not able to test the tooltip behaviour properly
  78. // unless using requireWindowFocusForIE() { return true; } .
  79. // See #13854.
  80. // On Firefox, the driver causes additional mouseOut events causing the
  81. // tooltip to disappear immediately. Tooltips may work in some
  82. // particular cases, but not in general.
  83. return getBrowserCapabilities(Browser.CHROME, Browser.PHANTOMJS);
  84. }
  85. @Override
  86. public List<DesiredCapabilities> getBrowsersToTest() {
  87. // Uncomment Safari and Opera if those become tested browsers again.
  88. return getBrowserCapabilities(Browser.IE8, Browser.IE9, Browser.IE10,
  89. Browser.IE11, Browser.FIREFOX, Browser.CHROME,
  90. Browser.PHANTOMJS /* , Browser.SAFARI, Browser.OPERA */);
  91. }
  92. protected List<DesiredCapabilities> getBrowserCapabilities(
  93. Browser... browsers) {
  94. List<DesiredCapabilities> capabilities = new ArrayList<DesiredCapabilities>();
  95. for (Browser browser : browsers) {
  96. capabilities.add(browser.getDesiredCapabilities());
  97. }
  98. return capabilities;
  99. }
  100. }