GhostDriver で Selenium を使用していますが、次のエラーが表示されることがあります。Selenium の findbyElement、findByElements、get、click メソッドを使用した場合に発生します。
常に同じ場所で発生するわけではありませんが、Windows 環境ではより頻繁に発生します。
この例外を回避する方法を知っている人はいますか?
待機を使用しながら時間を追加しようとしましたが、うまくいきませんでした。
GhostDriver で Selenium を使用していますが、次のエラーが表示されることがあります。Selenium の findbyElement、findByElements、get、click メソッドを使用した場合に発生します。
常に同じ場所で発生するわけではありませんが、Windows 環境ではより頻繁に発生します。
この例外を回避する方法を知っている人はいますか?
待機を使用しながら時間を追加しようとしましたが、うまくいきませんでした。
これは私のために働いた:http://matejtymes.blogspot.co.uk/2014/10/webdriver-fix-for-unreachablebrowserexc.html
PhantomJSDriver を使用する場所ならどこでも使用できます (get、click、findByElement など、すべての状況をカバーします)。
public class FixedPhantomJSDriver extends PhantomJSDriver {
private final int retryCount = 2;
public FixedPhantomJSDriver() {
}
public FixedPhantomJSDriver(Capabilities desiredCapabilities) {
super(desiredCapabilities);
}
public FixedPhantomJSDriver(PhantomJSDriverService service, Capabilities desiredCapabilities) {
super(service, desiredCapabilities);
}
@Override
protected Response execute(String driverCommand, Map<String, ?> parameters) {
int retryAttempt = 0;
while (true) {
try {
return super.execute(driverCommand, parameters);
} catch (UnreachableBrowserException e) {
retryAttempt++;
if (retryAttempt > retryCount) {
throw e;
}
}
}
}
}