Uses Firefox either from path or from the location given using firefox.path in /work/run-eclipse-run-selected-test.properties Change-Id: I29faa94cac4c978792a8fab9db338048553d166atags/7.1.8
* If something goes wrong | * If something goes wrong | ||||
*/ | */ | ||||
protected void setupDriver() throws Exception { | protected void setupDriver() throws Exception { | ||||
if (runLocally()) { | |||||
setupLocalDriver(); | |||||
return; | |||||
} | |||||
DesiredCapabilities capabilities = getDesiredCapabilities(); | DesiredCapabilities capabilities = getDesiredCapabilities(); | ||||
WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( | WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( | ||||
} | } | ||||
/** | |||||
* Override and return true to run the test locally. This method is only to | |||||
* be used for developing tests. | |||||
* | |||||
* @return true to run the test on a local browser, false to use the hub | |||||
*/ | |||||
public boolean runLocally() { | |||||
return false; | |||||
} | |||||
/** | |||||
* Creates a {@link WebDriver} instance used for running the test locally | |||||
* for debug purposes. Used only when {@link #runLocally()} is overridden to | |||||
* return true; | |||||
*/ | |||||
protected abstract void setupLocalDriver(); | |||||
/** | /** | ||||
* Opens the given test (defined by {@link #getTestUrl(boolean, boolean)}, | * Opens the given test (defined by {@link #getTestUrl(boolean, boolean)}, | ||||
* optionally with debug window and/or push | * optionally with debug window and/or push | ||||
// Do nothing by default | // Do nothing by default | ||||
} | } | ||||
} | } |
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Properties; | import java.util.Properties; | ||||
import org.openqa.selenium.WebDriver; | |||||
import org.openqa.selenium.firefox.FirefoxBinary; | |||||
import org.openqa.selenium.firefox.FirefoxDriver; | |||||
import com.vaadin.testbench.TestBench; | |||||
/** | /** | ||||
* Provides values for parameters which depend on where the test is run. | * Provides values for parameters which depend on where the test is run. | ||||
* Parameters should be configured in work/eclipse-run-selected-test.properties. | * Parameters should be configured in work/eclipse-run-selected-test.properties. | ||||
"No compatible (192.168.*) ip address found."); | "No compatible (192.168.*) ip address found."); | ||||
} | } | ||||
/* | |||||
* (non-Javadoc) | |||||
* | |||||
* @see com.vaadin.tests.tb3.AbstractTB3Test#setupLocalDriver() | |||||
*/ | |||||
@Override | |||||
protected void setupLocalDriver() { | |||||
String firefoxPath = getProperty("firefox.path"); | |||||
WebDriver driver; | |||||
if (firefoxPath != null) { | |||||
driver = new FirefoxDriver( | |||||
new FirefoxBinary(new File(firefoxPath)), null); | |||||
} else { | |||||
driver = new FirefoxDriver(); | |||||
} | |||||
setDriver(TestBench.createDriver(driver)); | |||||
setDesiredCapabilities(BrowserUtil | |||||
.firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); | |||||
} | |||||
} | } |
package com.vaadin.tests.tb3; | package com.vaadin.tests.tb3; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.util.ArrayList; | |||||
import java.util.Collection; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.concurrent.ExecutorService; | import java.util.concurrent.ExecutorService; | ||||
try { | try { | ||||
AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass() | AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass() | ||||
.getOnlyConstructor().newInstance(); | .getOnlyConstructor().newInstance(); | ||||
for (DesiredCapabilities capabilities : testClassInstance | |||||
.getBrowsersToTest()) { | |||||
Collection<DesiredCapabilities> desiredCapabilites = testClassInstance | |||||
.getBrowsersToTest(); | |||||
if (testClassInstance.runLocally()) { | |||||
desiredCapabilites = new ArrayList<DesiredCapabilities>(); | |||||
desiredCapabilites.add(BrowserUtil | |||||
.firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); | |||||
} | |||||
for (DesiredCapabilities capabilities : desiredCapabilites) { | |||||
// Find any methods marked with @Test. | // Find any methods marked with @Test. | ||||
for (FrameworkMethod m : getTestClass().getAnnotatedMethods( | for (FrameworkMethod m : getTestClass().getAnnotatedMethods( |