| OLD | NEW |
| 1 Index: java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriv
erSupplier.java | 1 Index: java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.jav
a |
| 2 =================================================================== | 2 =================================================================== |
| 3 --- java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverS
upplier.java» (revision 18370) | 3 --- java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java»
(revision 17049) |
| 4 +++ java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverS
upplier.java» (working copy) | 4 +++ java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java»
(working copy) |
| 5 @@ -87,7 +87,7 @@ | 5 @@ -74,6 +74,10 @@ |
| 6 if (DesiredCapabilities.android().getBrowserName().equals(name)) { | 6 if (chromePath != null) { |
| 7 className = "org.openqa.selenium.android.AndroidDriver"; | 7 options.setBinary(new File(chromePath)); |
| 8 } else if (DesiredCapabilities.chrome().getBrowserName().equals(name)) { | 8 } |
| 9 - className = "org.openqa.selenium.testing.drivers.TestChromeDriver"; | 9 + String androidPackage = System.getProperty("webdriver.chrome.android_packag
e"); |
| 10 + className = "org.openqa.selenium.testing.drivers.TestNewChromeDriver"; | 10 + if (androidPackage != null) { |
| 11 } else if (DesiredCapabilities.firefox().getBrowserName().equals(name)) { | 11 + options.setAndroidPackage(androidPackage); |
| 12 className = getFirefoxClassName(); | 12 + } |
| 13 } else if (DesiredCapabilities.htmlUnit().getBrowserName().equals(name)) { | 13 |
| 14 Index: java/client/test/org/openqa/selenium/testing/drivers/build.desc | 14 DesiredCapabilities capabilities = DesiredCapabilities.chrome(); |
| 15 capabilities.setCapability(ChromeOptions.CAPABILITY, options); |
| 16 Index: java/client/src/org/openqa/selenium/chrome/ChromeOptions.java |
| 15 =================================================================== | 17 =================================================================== |
| 16 --- java/client/test/org/openqa/selenium/testing/drivers/build.desc» (revisio
n 18370) | 18 --- java/client/src/org/openqa/selenium/chrome/ChromeOptions.java» (revisio
n 17049) |
| 17 +++ java/client/test/org/openqa/selenium/testing/drivers/build.desc» (working
copy) | 19 +++ java/client/src/org/openqa/selenium/chrome/ChromeOptions.java» (working
copy) |
| 18 @@ -9,6 +9,7 @@ | 20 @@ -65,6 +65,7 @@ |
| 19 "SauceDriver.java", | 21 public static final String CAPABILITY = "chromeOptions"; |
| 20 "SynthesizedFirefoxDriver.java", | 22 |
| 21 "TestChromeDriver.java", | 23 private File binary; |
| 22 + "TestNewChromeDriver.java", | 24 + private String androidPackage; |
| 23 "TestIgnorance.java", | 25 private List<String> args = Lists.newArrayList(); |
| 24 "TestInternetExplorerDriver.java", | 26 private List<File> extensionFiles = Lists.newArrayList(); |
| 25 "WebDriverBuilder.java", | 27 private Map<String, Object> experimentalOptions = Maps.newHashMap(); |
| 26 Index: java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.
java | 28 @@ -81,6 +82,16 @@ |
| 27 =================================================================== | 29 } |
| 28 --- java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.jav
a» (revision 0) | 30 |
| 29 +++ java/client/test/org/openqa/selenium/testing/drivers/TestNewChromeDriver.jav
a» (revision 0) | 31 /** |
| 30 @@ -0,0 +1,56 @@ | 32 + * Sets the Android package name for Chrome. The package should already exist |
| 31 +/* | 33 + * on the Android device. |
| 32 +Copyright 2012 Selenium committers | 34 + * |
| 33 +Copyright 2012 Software Freedom Conservancy | 35 + * @param package_name Name of Chrome's Android package. |
| 34 + | 36 + */ |
| 35 +Licensed under the Apache License, Version 2.0 (the "License"); | 37 + public void setAndroidPackage(String package_name) { |
| 36 +you may not use this file except in compliance with the License. | 38 + androidPackage = checkNotNull(package_name); |
| 37 +You may obtain a copy of the License at | |
| 38 + | |
| 39 + http://www.apache.org/licenses/LICENSE-2.0 | |
| 40 + | |
| 41 +Unless required by applicable law or agreed to in writing, software | |
| 42 +distributed under the License is distributed on an "AS IS" BASIS, | |
| 43 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 44 +See the License for the specific language governing permissions and | |
| 45 +limitations under the License. | |
| 46 +*/ | |
| 47 + | |
| 48 +package org.openqa.selenium.testing.drivers; | |
| 49 + | |
| 50 +import org.openqa.selenium.Capabilities; | |
| 51 +import org.openqa.selenium.chrome.ChromeOptions; | |
| 52 +import org.openqa.selenium.chrome.NewCommandExecutor; | |
| 53 +import org.openqa.selenium.remote.DesiredCapabilities; | |
| 54 +import org.openqa.selenium.remote.RemoteWebDriver; | |
| 55 + | |
| 56 +import java.io.File; | |
| 57 + | |
| 58 +public class TestNewChromeDriver extends RemoteWebDriver { | |
| 59 + | |
| 60 + public TestNewChromeDriver() { | |
| 61 + this(chromeWithCustomCapabilities(null)); | |
| 62 + } | 39 + } |
| 63 + | 40 + |
| 64 + public TestNewChromeDriver(Capabilities capabilities) { | 41 + /** |
| 65 + super(new NewCommandExecutor(), chromeWithCustomCapabilities(capabilities))
; | 42 * @param arguments The arguments to use when starting Chrome. |
| 66 + } | 43 * @see #addArguments(java.util.List) |
| 67 + | 44 */ |
| 68 + private static DesiredCapabilities chromeWithCustomCapabilities( | 45 @@ -147,6 +158,10 @@ |
| 69 + Capabilities originalCapabilities) { | 46 options.put("binary", binary.getPath()); |
| 70 + ChromeOptions options = new ChromeOptions(); | 47 } |
| 71 + options.addArguments("disable-extensions"); | 48 |
| 72 + String chromePath = System.getProperty("webdriver.chrome.binary"); | 49 + if (androidPackage != null) { |
| 73 + if (chromePath != null) { | 50 + options.put("android_package", androidPackage); |
| 74 + options.setBinary(new File(chromePath)); | |
| 75 + } | 51 + } |
| 76 + | 52 + |
| 77 + DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | 53 options.put("args", ImmutableList.copyOf(args)); |
| 78 + capabilities.setCapability(ChromeOptions.CAPABILITY, options); | 54 |
| 79 + | 55 List<String> extensions = Lists.newArrayListWithExpectedSize( |
| 80 + if (originalCapabilities != null) { | |
| 81 + capabilities.merge(originalCapabilities); | |
| 82 + } | |
| 83 + | |
| 84 + return capabilities; | |
| 85 + } | |
| 86 +} | |
| 87 Index: java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java | |
| 88 =================================================================== | |
| 89 --- java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java» (revisio
n 0) | |
| 90 +++ java/client/src/org/openqa/selenium/chrome/NewCommandExecutor.java» (revisio
n 0) | |
| 91 @@ -0,0 +1,53 @@ | |
| 92 +/* | |
| 93 +Copyright 2012 Selenium committers | |
| 94 +Copyright 2012 Software Freedom Conservancy | |
| 95 + | |
| 96 +Licensed under the Apache License, Version 2.0 (the "License"); | |
| 97 +you may not use this file except in compliance with the License. | |
| 98 +You may obtain a copy of the License at | |
| 99 + | |
| 100 + http://www.apache.org/licenses/LICENSE-2.0 | |
| 101 + | |
| 102 +Unless required by applicable law or agreed to in writing, software | |
| 103 +distributed under the License is distributed on an "AS IS" BASIS, | |
| 104 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 105 +See the License for the specific language governing permissions and | |
| 106 +limitations under the License. | |
| 107 +*/ | |
| 108 + | |
| 109 +package org.openqa.selenium.chrome; | |
| 110 + | |
| 111 +import org.openqa.selenium.remote.BeanToJsonConverter; | |
| 112 +import org.openqa.selenium.remote.Command; | |
| 113 +import org.openqa.selenium.remote.CommandExecutor; | |
| 114 +import org.openqa.selenium.remote.JsonToBeanConverter; | |
| 115 +import org.openqa.selenium.remote.Response; | |
| 116 + | |
| 117 +import java.io.IOException; | |
| 118 +import java.util.HashMap; | |
| 119 +import java.util.Map; | |
| 120 + | |
| 121 +/** | |
| 122 + * Executes a ChromeDriver command using the new ChromeDriver. | |
| 123 + */ | |
| 124 +public class NewCommandExecutor implements CommandExecutor { | |
| 125 + | |
| 126 + static { | |
| 127 + System.loadLibrary("chromedriver"); | |
| 128 + } | |
| 129 + | |
| 130 + @Override | |
| 131 + public Response execute(Command command) throws IOException { | |
| 132 + Map<String, Object> jsonCommand = new HashMap<String, Object>(); | |
| 133 + jsonCommand.put("name", command.getName()); | |
| 134 + jsonCommand.put("parameters", command.getParameters()); | |
| 135 + String id = ""; | |
| 136 + if (command.getSessionId() != null) | |
| 137 + id = command.getSessionId().toString(); | |
| 138 + jsonCommand.put("sessionId", id); | |
| 139 + String responseText = execute(new BeanToJsonConverter().convert(jsonCommand
)); | |
| 140 + return new JsonToBeanConverter().convert(Response.class, responseText); | |
| 141 + } | |
| 142 + | |
| 143 + private static native String execute(String command); | |
| 144 +} | |
| OLD | NEW |