Skip to content

Commit 05115be

Browse files
committed
IE tweak
1 parent 3aa7a68 commit 05115be

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

SeleniumTester/src/test/java/org/loverde/jquery/restrictedtextfield/selenium/tests/AbstractTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.loverde.jquery.restrictedtextfield.selenium.driver.DriverFactory;
6161
import org.loverde.jquery.restrictedtextfield.selenium.util.StringUtil;
6262
import org.openqa.selenium.By;
63-
import org.openqa.selenium.Capabilities;
6463
import org.openqa.selenium.JavascriptExecutor;
6564
import org.openqa.selenium.WebDriver;
6665
import org.openqa.selenium.WebElement;
@@ -108,8 +107,9 @@ public abstract class AbstractTest {
108107

109108
private static BufferedWriter log = null;
110109

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;
113113

114114

115115
@Parameters( name = "{1}" )
@@ -1064,7 +1064,12 @@ public AbstractTest( final FieldType fieldType,
10641064
throw new IllegalStateException( "IE driver is null" );
10651065
} else {
10661066
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;
10681073
}
10691074
} else if( clazz == FirefoxTest.class ) {
10701075
final String geckoPath = props.getProperty( APP_PROP_GECKO_DRIVER_PATH );
@@ -1112,7 +1117,6 @@ public AbstractTest( final FieldType fieldType,
11121117

11131118
@BeforeClass
11141119
public static void init() throws IOException {
1115-
doPeriodicReload = false;
11161120
testCount = 0;
11171121

11181122
if( logDirectory == null ) {
@@ -1150,20 +1154,17 @@ public void setUp() throws Exception {
11501154
public void tearDown() throws Exception {
11511155
javascript( "return tearDown();" );
11521156

1153-
if( doPeriodicReload ) {
1154-
if( ++reloadCount >= 10 ) {
1155-
ieMemoryLeakFix();
1157+
if( reloadFrequency > 0 ) {
1158+
if( ++reloadCount >= reloadFrequency ) {
1159+
reloadPage();
11561160
reloadCount = 0;
11571161
}
11581162
}
11591163
}
11601164

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.
11671168
}
11681169

11691170
@Test

test/test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
<h1>RestrictedTextField</h1>
196196
<p>https://www.github.com/kloverde/jquery-RestrictedTextField</p>
197197
<h1>AUTOMATED TESTING IN PROGRESS</h1>
198-
<h2>Do not disturb this machine</h2>
198+
<h2>Do not disturb this machine - walk away!</h2>
199199

200200
<div id="fieldContainer" class="center"></div>
201201

0 commit comments

Comments
 (0)