Last active
February 5, 2020 08:31
-
-
Save nickgrealy/267fd8016bc84eddeb50 to your computer and use it in GitHub Desktop.
Class to synchronise calls to the WebDriver instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package selenium.webdrivers; | |
import org.openqa.selenium.Capabilities; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriverService; | |
import org.openqa.selenium.remote.Response; | |
import java.util.Map; | |
/** | |
* A synchronised implementation of the InternetExplorerDriver. Workaround for Selenium issue: | |
* <a href="http://code.google.com/p/selenium/issues/detail?id=6592">IE Driver returns 404: File not found</a>. | |
* <p/> | |
* <b>N.B.</b> synchronises the execute(...) methods. | |
* | |
* @author [email protected] | |
* @version 1.0 | |
* @since 27/08/2014 | |
*/ | |
public class SynchronizedInternetExplorerDriver extends InternetExplorerDriver { | |
private Object lock; | |
/* constructors */ | |
public SynchronizedInternetExplorerDriver() { | |
super(); | |
} | |
public SynchronizedInternetExplorerDriver(Capabilities capabilities) { | |
super(capabilities); | |
} | |
public SynchronizedInternetExplorerDriver(int port) { | |
super(port); | |
} | |
public SynchronizedInternetExplorerDriver(InternetExplorerDriverService service) { | |
super(service); | |
} | |
public SynchronizedInternetExplorerDriver(InternetExplorerDriverService service, Capabilities capabilities) { | |
super(service, capabilities); | |
} | |
public SynchronizedInternetExplorerDriver(InternetExplorerDriverService service, Capabilities capabilities, int port) { | |
super(service, capabilities, port); | |
} | |
/* overrides */ | |
@Override | |
protected Response execute(String driverCommand, Map<String, ?> parameters) { | |
synchronized (getLock()) { | |
return super.execute(driverCommand, parameters); | |
} | |
} | |
@Override | |
protected Response execute(String command) { | |
synchronized (getLock()) { | |
return super.execute(command); | |
} | |
} | |
/* getters */ | |
public Object getLock() { | |
if (lock == null) { | |
// class level variable is not initialised if called from within constructor. | |
lock = new Object(); | |
} | |
return lock; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment