File tree 5 files changed +44
-1
lines changed
java/client/src/org/openqa/selenium
5 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,20 @@ public void createProfile(String profileName) throws IOException {
207
207
public void waitFor () throws InterruptedException , IOException {
208
208
process .waitFor ();
209
209
}
210
+
211
+ /**
212
+ * Waits for the process to execute, returning the command output taken from the profile's
213
+ * execution.
214
+ *
215
+ * @param timeout the maximum time to wait in milliseconds
216
+ * @throws InterruptedException if we are interrupted while waiting for the process to launch
217
+ * @throws IOException if there is a problem with reading the input stream of the launching
218
+ * process
219
+ */
220
+
221
+ public void waitFor (long timeout ) throws InterruptedException , IOException {
222
+ process .waitFor (timeout );
223
+ }
210
224
211
225
/**
212
226
* Gets all console output of the binary. Output retrieval is non-destructive and non-blocking.
@@ -225,7 +239,7 @@ public String getConsoleOutput() throws IOException {
225
239
public void clean (FirefoxProfile profile , File profileDir ) throws IOException {
226
240
startProfile (profile , profileDir , "-silent" );
227
241
try {
228
- waitFor ();
242
+ waitFor (timeout );
229
243
} catch (InterruptedException e ) {
230
244
process .destroy ();
231
245
throw new WebDriverException (e );
Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ public void waitFor() {
123
123
throw new WebDriverException (e );
124
124
}
125
125
}
126
+
127
+ public void waitFor (long timeout ) {
128
+ try {
129
+ process .waitFor (timeout );
130
+ } catch (InterruptedException e ) {
131
+ throw new WebDriverException (e );
132
+ }
133
+ }
126
134
127
135
public boolean isSuccessful () {
128
136
return 0 == getExitCode ();
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ interface OsProcess {
35
35
void executeAsync ();
36
36
37
37
void waitFor () throws InterruptedException ;
38
+
39
+ void waitFor (long timeout ) throws InterruptedException ;
38
40
39
41
int destroy ();
40
42
Original file line number Diff line number Diff line change @@ -134,6 +134,21 @@ public void waitFor() throws InterruptedException {
134
134
handler .waitFor ();
135
135
}
136
136
137
+ public void waitFor (long timeout ) throws InterruptedException {
138
+ long until = System .currentTimeMillis () + timeout ;
139
+ boolean timedOut = true ;
140
+ while (System .currentTimeMillis () < until ) {
141
+ if (handler .hasResult ()){
142
+ timedOut = false ;
143
+ break ;
144
+ }
145
+ Thread .sleep (50 );
146
+ }
147
+ if (timedOut ){
148
+ throw new InterruptedException (String .format ("Process timed out after waiting for %d ms." ,timeout ) );
149
+ }
150
+ }
151
+
137
152
public boolean isRunning () {
138
153
return !handler .hasResult ();
139
154
}
Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ public void executeAsync() {
156
156
public void waitFor () throws InterruptedException {
157
157
// no-op
158
158
}
159
+
160
+ public void waitFor (long timeout ) throws InterruptedException {
161
+ // no-op
162
+ }
159
163
160
164
public int destroy () {
161
165
if (!isRunning ()) {
You can’t perform that action at this time.
0 commit comments