From ae0b27bcaa8e7711515525b8f621500231e9bf67 Mon Sep 17 00:00:00 2001 From: Ross Rowe Date: Fri, 14 Jun 2013 17:11:12 +1000 Subject: [PATCH 1/2] Added support for specifying browser information as a JSON String or Array --- .../yuitest/selenium/SeleniumDriver.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java b/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java index 60ae300..8fc6458 100644 --- a/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java +++ b/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java @@ -22,6 +22,9 @@ import com.yahoo.platform.yuitest.config.TestPageGroup; import com.yahoo.platform.yuitest.coverage.results.SummaryCoverageReport; import com.yahoo.platform.yuitest.results.TestReport; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; /** * Controls Selenium to extract YUI Test information. @@ -428,12 +431,32 @@ private SessionResult runTestPage(Selenium selenium, String browser, //-------------------------------------------------------------------------- /** - * Splits the comma-delimited list of browsers into an array of strings. + * Attempts to parse the 'selenium.browsers' property as a JSON String. If the property is not a JSON string, + * splits the comma-delimited list of browsers into an array of strings. * @throws Exception If there are no browsers specified. */ private void getBrowserList() throws Exception { browsers = (properties.getProperty("selenium.browsers", "")).split("\\,"); + try { + //try parse as a JSON Array + JSONArray jsonArray = new JSONArray(browsersText); + browsers = new String[jsonArray.length()]; + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + browsers[i] = jsonObject.toString(); + } + } catch (JSONException e) { + try { + //try parse as a JSON Object + new JSONObject(browsersText); + browsers = new String[1]; + browsers[0] = browsersText; + } catch (JSONException e1) { + //fall back to splitting input string on , + browsers = browsersText.split("\\,"); + } + } if(browsers.length == 0){ throw new Exception("The configuration property 'selenium.browsers' is missing."); } From 15b99361c8a553904afc77e067819076d0e6c486 Mon Sep 17 00:00:00 2001 From: Ross Rowe Date: Fri, 23 Aug 2013 06:03:45 +1000 Subject: [PATCH 2/2] Added support for specifying browser information as a JSON String or Array --- .../src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java b/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java index 8fc6458..4d1a405 100644 --- a/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java +++ b/java/src/com/yahoo/platform/yuitest/selenium/SeleniumDriver.java @@ -437,7 +437,7 @@ private SessionResult runTestPage(Selenium selenium, String browser, */ private void getBrowserList() throws Exception { - browsers = (properties.getProperty("selenium.browsers", "")).split("\\,"); + String browsersText = properties.getProperty("selenium.browsers", ""); try { //try parse as a JSON Array JSONArray jsonArray = new JSONArray(browsersText);