Skip to content

Commit

Permalink
Migrate the WebDriverBackedSelenium to com.thoughtworks.selenium.webd…
Browse files Browse the repository at this point in the history
…riven.

And leave behind a deprecated implementation of each of the key interfaces to
ease migration for users. Also support building this all with Buck.
  • Loading branch information
shs96c committed Jan 5, 2014
1 parent af03db0 commit cbaa765
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 370 deletions.
8 changes: 8 additions & 0 deletions java/client/src/com/thoughtworks/selenium/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ java_library(name = 'selenium',
],
visibility = ['PUBLIC'],
)


java_binary(name = "legacy-selenium-client",
deps = [
':selenium',
'//java/client/src/com/thoughtworks/selenium/webdriven:webdriven',
],
)
7 changes: 7 additions & 0 deletions java/client/src/com/thoughtworks/selenium/webdriven/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
java_library(name = 'webdriven',
srcs = [
'CompoundMutator.java',
'ExplodingSupplier.java',
'FunctionDeclaration.java',
'SeleniumMutator.java',
'VariableDeclaration.java',
'WebDriverBackedSelenium.java',
'WebDriverCommandProcessor.java',
],
resources = [
'htmlutils.js',
Expand All @@ -28,9 +31,13 @@ java_library(name = 'webdriven',
],
deps = [
'//java/client/src/com/thoughtworks/selenium:selenium',
'//java/client/src/com/thoughtworks/selenium/webdriven/commands:commands',
'//java/client/src/org/openqa/selenium:webdriver-api',
'//third_party/java/guava-libraries:guava-libraries',
],
visibility = [
'//java/client/src/com/thoughtworks/selenium/...',
],
)

java_library(name = 'emulation-api',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
limitations under the License.
*/

package org.openqa.selenium;
package com.thoughtworks.selenium.webdriven;

import com.google.common.base.Supplier;

import org.openqa.selenium.WebDriver;

// Visibility set to package level deliberately
class ExplodingSupplier implements Supplier<WebDriver> {
public WebDriver get() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2007-2009 Selenium committers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.thoughtworks.selenium.webdriven;

import com.google.common.base.Supplier;

import com.thoughtworks.selenium.DefaultSelenium;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.HasCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.internal.WrapsDriver;

public class WebDriverBackedSelenium extends DefaultSelenium
implements HasCapabilities, WrapsDriver {
public WebDriverBackedSelenium(Supplier<WebDriver> maker, String baseUrl) {
super(new WebDriverCommandProcessor(baseUrl, maker));
}

public WebDriverBackedSelenium(WebDriver baseDriver, String baseUrl) {
super(new WebDriverCommandProcessor(baseUrl, baseDriver));
}

public WebDriver getWrappedDriver() {
return ((WrapsDriver) commandProcessor).getWrappedDriver();
}

@Override
public Capabilities getCapabilities() {
WebDriver driver = getWrappedDriver();
if (driver instanceof HasCapabilities) {
return ((HasCapabilities) driver).getCapabilities();
}

return null;
}
}
Loading

0 comments on commit cbaa765

Please sign in to comment.