
com.googlecode.jmeter.plugins.webdriver.config.InternetExplorerDriverConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-plugins-webdriver Show documentation
Show all versions of jmeter-plugins-webdriver Show documentation
Custom plugins set for Apache JMeter
package com.googlecode.jmeter.plugins.webdriver.config;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class InternetExplorerDriverConfig extends WebDriverConfig {
private static final long serialVersionUID = 100L;
private static final Logger LOGGER = LoggingManager.getLoggerForClass();
private static final String IE_SERVICE_PATH = "InternetExplorerDriverConfig.iedriver_path";
private static final Map services = new ConcurrentHashMap();
public void setInternetExplorerDriverPath(String path) {
setProperty(IE_SERVICE_PATH, path);
}
public String getInternetExplorerDriverPath() {
return getPropertyAsString(IE_SERVICE_PATH);
}
Capabilities createCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, createProxy());
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
return capabilities;
}
Map getServices() {
return services;
}
@Override
protected InternetExplorerDriver createBrowser() {
final InternetExplorerDriverService service = getThreadService();
return service != null ? new InternetExplorerDriver(service, createCapabilities()) : null;
}
@Override
public void quitBrowser(final InternetExplorerDriver browser) {
super.quitBrowser(browser);
final InternetExplorerDriverService service = services.remove(currentThreadName());
if (service != null && service.isRunning()) {
service.stop();
}
}
private InternetExplorerDriverService getThreadService() {
InternetExplorerDriverService service = services.get(currentThreadName());
if (service != null) {
return service;
}
try {
service = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File(getInternetExplorerDriverPath())).build();
service.start();
services.put(currentThreadName(), service);
} catch (IOException e) {
LOGGER.error("Failed to start chrome service");
service = null;
}
return service;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy