Skip to content

Commit b22f77a

Browse files
committed
fix cast exception for safaridriver on startup
1 parent e09e769 commit b22f77a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

java/client/src/org/openqa/selenium/safari/SafariDriver.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,26 @@ public void setFileDetector(FileDetector detector) {
9696

9797
@Override
9898
protected void startClient() {
99-
SafariDriverCommandExecutor executor = (SafariDriverCommandExecutor) this.getCommandExecutor();
100-
try {
101-
executor.start();
102-
} catch (IOException e) {
103-
throw new WebDriverException(e);
99+
CommandExecutor commandExecutor = this.getCommandExecutor();
100+
if (commandExecutor instanceof SafariDriverCommandExecutor) {
101+
try {
102+
((SafariDriverCommandExecutor)commandExecutor).start();
103+
} catch (IOException e) {
104+
throw new WebDriverException(e);
105+
}
106+
} else {
107+
super.startClient();
104108
}
105109
}
106110

107111
@Override
108112
protected void stopClient() {
109-
SafariDriverCommandExecutor executor = (SafariDriverCommandExecutor) this.getCommandExecutor();
110-
executor.stop();
113+
CommandExecutor commandExecutor = this.getCommandExecutor();
114+
if (commandExecutor instanceof SafariDriverCommandExecutor) {
115+
((SafariDriverCommandExecutor)commandExecutor).stop();
116+
} else {
117+
super.stopClient();
118+
}
111119
}
112120

113121
@Override

0 commit comments

Comments
 (0)