Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/SearchContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import java.util.List;

public interface SearchContext {
public interface SearchContext{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

/**
* Find all elements within the current context using the given mechanism.
*
* @param by The locating mechanism to use
* @return A list of all {@link WebElement}s, or an empty list if nothing matches
* @see org.openqa.selenium.By
*/
List<WebElement> findElements(By by);
<W extends WebElement> List<W> findElements(By by);


/**
Expand Down
72 changes: 72 additions & 0 deletions java/client/test/org/openqa/selenium/SearchContextTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.openqa.selenium;

import org.junit.Test;

import java.util.List;

// this class just tests we can compile the code
public class SearchContextTest {

private final SubClassingSearchContext subClassingSearchContext = new SubClassingSearchContext();
private final SameClassSearchContext sameClassSearchContext = new SameClassSearchContext() {
@Override
public List<WebElement> findElements(By by) {
return null;
}

@Override
public WebElement findElement(By by) {
return null;
}
};

private interface TestWebElement extends WebElement {

}

private static class SubClassingSearchContext implements SearchContext {

@Override
public List<TestWebElement> findElements(By by) {
return null;
}

@Override
public TestWebElement findElement(By by) {
return null;
}
}

private interface SameClassSearchContext extends SearchContext {

}

@Test
public void makeSureFindElementsIsBackwardsCompatible() throws Exception {

@SuppressWarnings("unused")
List<? extends WebElement> elements = sameClassSearchContext.findElements(null);
}

@Test
public void makeSureFindElementIsBackwardsCompatible() throws Exception {

@SuppressWarnings("unused")
WebElement element = sameClassSearchContext.findElement(null);
}

@Test
public void makeSureFindElementsCanUseSuperClass() throws Exception {
@SuppressWarnings("unused")
List<TestWebElement> elements = subClassingSearchContext.findElements(null);
}

@Test
public void makeSureFindElementCanUseSuperClass() throws Exception {

@SuppressWarnings("unused")
WebElement element = subClassingSearchContext.findElement(null);


}
}