|
60 | 60 | import org.loverde.jquery.restrictedtextfield.selenium.driver.DriverFactory; |
61 | 61 | import org.loverde.jquery.restrictedtextfield.selenium.util.StringUtil; |
62 | 62 | import org.openqa.selenium.By; |
63 | | -import org.openqa.selenium.Capabilities; |
64 | 63 | import org.openqa.selenium.JavascriptExecutor; |
65 | 64 | import org.openqa.selenium.WebDriver; |
66 | 65 | import org.openqa.selenium.WebElement; |
@@ -108,8 +107,9 @@ public abstract class AbstractTest { |
108 | 107 |
|
109 | 108 | private static BufferedWriter log = null; |
110 | 109 |
|
111 | | - private static boolean doPeriodicReload = false; |
112 | | - private static int testCount = 0, reloadCount = 0; |
| 110 | + private static int testCount = 0, |
| 111 | + reloadCount = 0, |
| 112 | + reloadFrequency = 0; |
113 | 113 |
|
114 | 114 |
|
115 | 115 | @Parameters( name = "{1}" ) |
@@ -1064,7 +1064,12 @@ public AbstractTest( final FieldType fieldType, |
1064 | 1064 | throw new IllegalStateException( "IE driver is null" ); |
1065 | 1065 | } else { |
1066 | 1066 | System.out.println( "Got IE driver" ); |
1067 | | - doPeriodicReload = true; // All versions of IE leak memory when nodes are removed from the DOM |
| 1067 | + |
| 1068 | + // All versions of IE leak memory when nodes are removed from the DOM. |
| 1069 | + // Determine how often to reload the page. |
| 1070 | + |
| 1071 | + final String version = (((RemoteWebDriver) driver)).getCapabilities().getVersion(); |
| 1072 | + reloadFrequency = version.startsWith( "9" ) ? 1 : 10; |
1068 | 1073 | } |
1069 | 1074 | } else if( clazz == FirefoxTest.class ) { |
1070 | 1075 | final String geckoPath = props.getProperty( APP_PROP_GECKO_DRIVER_PATH ); |
@@ -1112,7 +1117,6 @@ public AbstractTest( final FieldType fieldType, |
1112 | 1117 |
|
1113 | 1118 | @BeforeClass |
1114 | 1119 | public static void init() throws IOException { |
1115 | | - doPeriodicReload = false; |
1116 | 1120 | testCount = 0; |
1117 | 1121 |
|
1118 | 1122 | if( logDirectory == null ) { |
@@ -1150,20 +1154,17 @@ public void setUp() throws Exception { |
1150 | 1154 | public void tearDown() throws Exception { |
1151 | 1155 | javascript( "return tearDown();" ); |
1152 | 1156 |
|
1153 | | - if( doPeriodicReload ) { |
1154 | | - if( ++reloadCount >= 10 ) { |
1155 | | - ieMemoryLeakFix(); |
| 1157 | + if( reloadFrequency > 0 ) { |
| 1158 | + if( ++reloadCount >= reloadFrequency ) { |
| 1159 | + reloadPage(); |
1156 | 1160 | reloadCount = 0; |
1157 | 1161 | } |
1158 | 1162 | } |
1159 | 1163 | } |
1160 | 1164 |
|
1161 | | - /** |
1162 | | - * All versions of IE leak memory when removing nodes from the DOM. This method reloads the page to free it up. |
1163 | | - */ |
1164 | | - private void ieMemoryLeakFix() throws Exception { |
1165 | | - log( "IE leak prevention" ); |
1166 | | - javascript( "window.location = window.location;" ); // Sending F5 reloads the page, but memory isn't freed |
| 1165 | + /** All versions of IE leak memory when removing nodes from the DOM. This method reloads the page to free it up. */ |
| 1166 | + private void reloadPage() throws Exception { |
| 1167 | + javascript( "return window.location = window.location;" ); // Sending F5 reloads the page, but memory isn't freed. This way works. |
1167 | 1168 | } |
1168 | 1169 |
|
1169 | 1170 | @Test |
|
0 commit comments