From cb789da24cb3f4db1b5069c78ff5ecd53a75035c Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 10 Feb 2015 18:06:39 +1000 Subject: [PATCH] Simplify webdriver config (use DISPLAY from env) --- functional-test/pom.xml | 6 +-- .../org/zanata/page/WebDriverFactory.java | 54 ++----------------- .../src/test/resources/setup.properties | 1 - pom.xml | 5 +- 4 files changed, 10 insertions(+), 56 deletions(-) diff --git a/functional-test/pom.xml b/functional-test/pom.xml index e692a7eaba..9d34428737 100644 --- a/functional-test/pom.xml +++ b/functional-test/pom.xml @@ -47,7 +47,6 @@ /opt/google/chrome/google-chrome chrome - :0 ${project.build.directory}/webdriver.log ${project.build.directory}/screenshots 10 @@ -779,6 +778,7 @@ or -Dappserver=wildfly8 NB: cargo.basename needs to match the basename of the file given in cargo.installation. For example, if cargo.installation is http://example.com/download/jboss-6.3.2.zip, cargo.basename should be jboss-6.3.2. + appserver.dir.name is top-level dir inside zip. For jbosseap6, default is jboss-eap-6.3. Override for later versions. -DallFuncTests to enable all functional tests (defaults to smoke tests) @@ -791,10 +791,10 @@ -Dzanata.sample.projects.basedir=${project.build.testOutputDirectory}/sample-projects -Dinclude.test.patterns=test filter pattern. Can be used to control what test to run. Default is ${default.test.patterns} -Dwebdriver.type=run tests in htmlUnit, chrome or firefox. For chrome, see also webdriver.chrome.* Default is chrome. - -Dwebdriver.display=display to run test browser in, for Xnest or otherwise. Default is :0. -Dwebdriver.chrome.bin=full path to chrome binary. - -Dwebdriver.chrome.driver=full path to chromedriver binary. + -Dwebdriver.chrome.driver=full path to chromedriver binary. Default is chromedriver on $PATH -Dwebdriver.wait=global wait time in seconds for element searches. Default is 10. + NB: set env var DISPLAY to run test browser in alternative display, for Xnest/Xvfb/Xvnc. eg: xvfb-run -e mvn verify -Dappserver=wildfly8 ========================================================== to ask cargo to start up then wait so that tests can be run manually: mvn clean package cargo:run -Dappserver=wildfly8 -Dmysql.port=13306 diff --git a/functional-test/src/main/java/org/zanata/page/WebDriverFactory.java b/functional-test/src/main/java/org/zanata/page/WebDriverFactory.java index f237312da8..9e826f047a 100644 --- a/functional-test/src/main/java/org/zanata/page/WebDriverFactory.java +++ b/functional-test/src/main/java/org/zanata/page/WebDriverFactory.java @@ -108,29 +108,9 @@ private WebDriver createPlainDriver() { } private WebDriver configureChromeDriver() { - // TODO can we use this? it will use less code, but it will use DISPLAY rather than webdriver.display -// System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, -// getChromeDriver().getAbsolutePath())); -// System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, -// PropertiesHolder.getProperty("webdriver.log")); -// driverService = ChromeDriverService.createDefaultService(); - - @SuppressWarnings("deprecation") - File chromeDriver = getChromeDriver(); - driverService = - new ChromeDriverService.Builder() - .usingDriverExecutable( - chromeDriver) - .usingAnyFreePort() - .withEnvironment( - ImmutableMap - .of("DISPLAY", - PropertiesHolder.properties - .getProperty("webdriver.display"))) - .withLogFile( - new File(PropertiesHolder.properties - .getProperty("webdriver.log"))).build(); - + System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, + PropertiesHolder.getProperty("webdriver.log")); + driverService = ChromeDriverService.createDefaultService(); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities .setCapability("chrome.binary", PropertiesHolder.properties @@ -146,32 +126,6 @@ private WebDriver configureChromeDriver() { capabilities))); } - /** - * Returns a File pointing to a chromedriver binary, searching the PATH - * if necessary. If the property 'webdriver.chrome.driver' points to an - * executable, uses that. Otherwise, searches PATH for the specified - * executable. Searches for 'chromedriver' if the property is null or - * empty. - * @return a File pointing to the executable - * @deprecated use ChromeDriverService.createDefaultService() if you can - */ - @Deprecated - private File getChromeDriver() { - String exeName = PropertiesHolder.getProperty("webdriver.chrome.driver"); - if (exeName == null || exeName.isEmpty()) { - exeName = CommandLine.find("chromedriver"); - } else if (!new File(exeName).canExecute()) { - exeName = CommandLine.find(exeName); - } - if (exeName == null) { - throw new RuntimeException("Please ensure chromedriver is on " + - "your system PATH or specified by the property " + - "'webdriver.chrome.driver'. Get it here: " + - "http://chromedriver.storage.googleapis.com/index.html"); - } - return new File(exeName); - } - private WebDriver configureFirefoxDriver() { final String pathToFirefox = Strings.emptyToNull(PropertiesHolder.properties @@ -187,8 +141,6 @@ private WebDriver configureFirefoxDriver() { * TODO: Evaluate current timeout Timeout the connection in 30 seconds * firefoxBinary.setTimeout(TimeUnit.SECONDS.toMillis(30)); */ - firefoxBinary.setEnvironmentProperty("DISPLAY", - PropertiesHolder.properties.getProperty("webdriver.display")); return new FirefoxDriver(firefoxBinary, makeFirefoxProfile()); } diff --git a/functional-test/src/test/resources/setup.properties b/functional-test/src/test/resources/setup.properties index 31bc94103b..9733c32b91 100644 --- a/functional-test/src/test/resources/setup.properties +++ b/functional-test/src/test/resources/setup.properties @@ -6,7 +6,6 @@ webdriver.chrome.driver=${webdriver.chrome.driver} #this decides what web driver type we intended to use. webdriver.type=${webdriver.type} webdriver.log=${webdriver.log} -webdriver.display=${webdriver.display} webdriver.screenshot.dir=${webdriver.screenshot.dir} webdriver.wait=${webdriver.wait} zanata.instance.url=${zanata.instance.url} diff --git a/pom.xml b/pom.xml index 5d811459d0..9c27017c51 100644 --- a/pom.xml +++ b/pom.xml @@ -1104,7 +1104,10 @@ run - + + + +