Skip to content

Commit e02b7ab

Browse files
browser: rename ElementValue -> PageElementValue (#800)
1 parent 01ea3bf commit e02b7ab

11 files changed

Lines changed: 43 additions & 43 deletions

File tree

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/expectation/ElementValueCompareToHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.testingisdocumenting.webtau.browser.expectation;
1919

20-
import org.testingisdocumenting.webtau.browser.page.ElementValue;
20+
import org.testingisdocumenting.webtau.browser.page.PageElementValue;
2121
import org.testingisdocumenting.webtau.expectation.ActualPath;
2222
import org.testingisdocumenting.webtau.expectation.equality.CompareToComparator;
2323
import org.testingisdocumenting.webtau.expectation.equality.CompareToHandler;
@@ -37,25 +37,25 @@ public boolean handleGreaterLessEqual(Object actual, Object expected) {
3737

3838
@Override
3939
public void compareEqualOnly(CompareToComparator comparator, ActualPath actualPath, Object actual, Object expected) {
40-
ElementValue<?> actualElementValue = (ElementValue<?>) actual;
40+
PageElementValue<?> actualElementValue = (PageElementValue<?>) actual;
4141
comparator.compareUsingEqualOnly(creataPath(actualElementValue), extractActualValue(actualElementValue), expected);
4242
}
4343

4444
@Override
4545
public void compareGreaterLessEqual(CompareToComparator comparator, ActualPath actualPath, Object actual, Object expected) {
46-
ElementValue<?> actualElementValue = (ElementValue<?>) actual;
46+
PageElementValue<?> actualElementValue = (PageElementValue<?>) actual;
4747
comparator.compareUsingCompareTo(creataPath(actualElementValue), extractActualValue(actualElementValue), expected);
4848
}
4949

50-
private Object extractActualValue(ElementValue<?> actualElementValue) {
50+
private Object extractActualValue(PageElementValue<?> actualElementValue) {
5151
return actualElementValue.get();
5252
}
5353

54-
private ActualPath creataPath(ElementValue<?> elementValue) {
54+
private ActualPath creataPath(PageElementValue<?> elementValue) {
5555
return createActualPath(elementValue.getName());
5656
}
5757

5858
private boolean handles(Object actual) {
59-
return actual instanceof ElementValue;
59+
return actual instanceof PageElementValue;
6060
}
6161
}

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/expectation/PageElementCompareToHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.testingisdocumenting.webtau.browser.expectation;
1919

20-
import org.testingisdocumenting.webtau.browser.page.ElementValue;
20+
import org.testingisdocumenting.webtau.browser.page.PageElementValue;
2121
import org.testingisdocumenting.webtau.browser.page.PageElement;
2222
import org.testingisdocumenting.webtau.expectation.ActualPath;
2323
import org.testingisdocumenting.webtau.expectation.equality.CompareToComparator;
@@ -40,21 +40,21 @@ public boolean handleGreaterLessEqual(Object actual, Object expected) {
4040

4141
@Override
4242
public void compareEqualOnly(CompareToComparator comparator, ActualPath actualPath, Object actual, Object expected) {
43-
ElementValue<?> elementValue = extractElementValue(actual, expected);
43+
PageElementValue<?> elementValue = extractElementValue(actual, expected);
4444
comparator.compareUsingEqualOnly(createPath(elementValue), elementValue, expected);
4545
}
4646

4747
@Override
4848
public void compareGreaterLessEqual(CompareToComparator comparator, ActualPath actualPath, Object actual, Object expected) {
49-
ElementValue<?> elementValue = extractElementValue(actual, expected);
49+
PageElementValue<?> elementValue = extractElementValue(actual, expected);
5050
comparator.compareUsingCompareTo(createPath(elementValue), elementValue, expected);
5151
}
5252

53-
private ActualPath createPath(ElementValue<?> elementValue) {
53+
private ActualPath createPath(PageElementValue<?> elementValue) {
5454
return createActualPath(elementValue.getName());
5555
}
5656

57-
private ElementValue<?> extractElementValue(Object actual, Object expected) {
57+
private PageElementValue<?> extractElementValue(Object actual, Object expected) {
5858
PageElement actualPageElement = (PageElement) actual;
5959
return expected instanceof List ?
6060
actualPageElement.elementValues():

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/NullWebElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ public <X> X getScreenshotAs(OutputType<X> outputType) throws WebDriverException
124124
}
125125

126126
public void error(String action) {
127-
throw new ElementNotFoundException("can't " + action + " as element is not found: " + id + ". Try to wait for it to appear first.");
127+
throw new PageElementNotFoundException("can't " + action + " as element is not found: " + id + ". Try to wait for it to appear first.");
128128
}
129129
}

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/PageElement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
import java.util.regex.Pattern;
3131

3232
public interface PageElement extends ActualValueExpectations, WithTokenizedDescription {
33-
ElementValue<Integer> getCount();
33+
PageElementValue<Integer> getCount();
3434

3535
WebElement findElement();
3636
List<WebElement> findElements();
3737

38-
ElementValue<Object> elementValue();
39-
ElementValue<List<Object>> elementValues();
38+
PageElementValue<Object> elementValue();
39+
PageElementValue<List<Object>> elementValues();
4040

4141
void setValue(Object value);
4242
void sendKeys(CharSequence keys);

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/ElementNotFoundException.java renamed to webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/PageElementNotFoundException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.testingisdocumenting.webtau.browser.page;
1818

19-
public class ElementNotFoundException extends AssertionError {
20-
public ElementNotFoundException(String message) {
19+
public class PageElementNotFoundException extends AssertionError {
20+
public PageElementNotFoundException(String message) {
2121
super(message);
2222
}
2323
}

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/ElementValue.java renamed to webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/PageElementValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
import static org.testingisdocumenting.webtau.reporter.IntegrationTestsMessageBuilder.OF;
2929
import static org.testingisdocumenting.webtau.reporter.TokenizedMessage.tokenizedMessage;
3030

31-
public class ElementValue<E> implements ActualValueExpectations {
31+
public class PageElementValue<E> implements ActualValueExpectations {
3232
private final WithTokenizedDescription parent;
3333
private final String name;
34-
private final ElementValueFetcher<E> valueFetcher;
34+
private final PageElementValueFetcher<E> valueFetcher;
3535

3636
private final TokenizedMessage description;
3737

38-
public ElementValue(WithTokenizedDescription parent, String name, ElementValueFetcher<E> valueFetcher) {
38+
public PageElementValue(WithTokenizedDescription parent, String name, PageElementValueFetcher<E> valueFetcher) {
3939
this.parent = parent;
4040
this.name = name;
4141
this.valueFetcher = valueFetcher;

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/ElementValueFetcher.java renamed to webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/PageElementValueFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
package org.testingisdocumenting.webtau.browser.page;
1919

20-
public interface ElementValueFetcher<E> {
20+
public interface PageElementValueFetcher<E> {
2121
E fetch();
2222
}

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/PageUrl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public PageUrl(Supplier<String> currentUrlSupplier) {
2929
this.currentUrlSupplier = currentUrlSupplier;
3030
}
3131

32-
public final ElementValue<String> full =
33-
new ElementValue<>(browserContext, "full page url", this::fetchUrl);
32+
public final PageElementValue<String> full =
33+
new PageElementValue<>(browserContext, "full page url", this::fetchUrl);
3434

35-
public final ElementValue<String> path =
36-
new ElementValue<>(browserContext, "page url path", this::fetchPath);
35+
public final PageElementValue<String> path =
36+
new PageElementValue<>(browserContext, "page url path", this::fetchPath);
3737

38-
public final ElementValue<String> query =
39-
new ElementValue<>(browserContext, "page url query", this::fetchQuery);
38+
public final PageElementValue<String> query =
39+
new PageElementValue<>(browserContext, "page url query", this::fetchQuery);
4040

41-
public final ElementValue<String> ref =
42-
new ElementValue<>(browserContext, "page url ref", this::fetchRef);
41+
public final PageElementValue<String> ref =
42+
new PageElementValue<>(browserContext, "page url ref", this::fetchRef);
4343

4444
public String get() {
4545
return fetchUrl();

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/page/path/GenericPageElement.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.testingisdocumenting.webtau.browser.page.path.filter.ByRegexpElementsFilter;
2727
import org.testingisdocumenting.webtau.browser.page.path.filter.ByTextElementsFilter;
2828
import org.testingisdocumenting.webtau.browser.page.path.finder.ByCssFinder;
29-
import org.testingisdocumenting.webtau.browser.page.ElementValue;
29+
import org.testingisdocumenting.webtau.browser.page.PageElementValue;
3030
import org.testingisdocumenting.webtau.browser.handlers.PageElementGetSetValueHandlers;
3131
import org.testingisdocumenting.webtau.reporter.StepReportOptions;
3232
import org.testingisdocumenting.webtau.reporter.TokenizedMessage;
@@ -51,20 +51,20 @@ public class GenericPageElement implements PageElement {
5151
private final AdditionalBrowserInteractions additionalBrowserInteractions;
5252
private final ElementPath path;
5353
private final TokenizedMessage pathDescription;
54-
private final ElementValue<Object> elementValue;
55-
private final ElementValue<Integer> countValue;
54+
private final PageElementValue<Object> elementValue;
55+
private final PageElementValue<Integer> countValue;
5656

5757
public GenericPageElement(WebDriver driver, AdditionalBrowserInteractions additionalBrowserInteractions, ElementPath path) {
5858
this.driver = driver;
5959
this.additionalBrowserInteractions = additionalBrowserInteractions;
6060
this.path = path;
6161
this.pathDescription = path.describe();
62-
this.elementValue = new ElementValue<>(this, "value", this::getUnderlyingValue);
63-
this.countValue = new ElementValue<>(this, "count", this::getNumberOfElements);
62+
this.elementValue = new PageElementValue<>(this, "value", this::getUnderlyingValue);
63+
this.countValue = new PageElementValue<>(this, "count", this::getNumberOfElements);
6464
}
6565

6666
@Override
67-
public ElementValue<Integer> getCount() {
67+
public PageElementValue<Integer> getCount() {
6868
return countValue;
6969
}
7070

@@ -139,13 +139,13 @@ public List<WebElement> findElements() {
139139
}
140140

141141
@Override
142-
public ElementValue<Object> elementValue() {
142+
public PageElementValue<Object> elementValue() {
143143
return elementValue;
144144
}
145145

146146
@Override
147-
public ElementValue<List<Object>> elementValues() {
148-
return new ElementValue<>(this, "all values", this::extractValues);
147+
public PageElementValue<List<Object>> elementValues() {
148+
return new PageElementValue<>(this, "all values", this::extractValues);
149149
}
150150

151151
@Override

webtau-browser/src/test/groovy/org/testingisdocumenting/webtau/browser/expectation/ElementValueCompareToHandlerTest.groovy renamed to webtau-browser/src/test/groovy/org/testingisdocumenting/webtau/browser/expectation/PageElementValueCompareToHandlerTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
package org.testingisdocumenting.webtau.browser.expectation
1818

19-
import org.testingisdocumenting.webtau.browser.page.ElementValue
19+
import org.testingisdocumenting.webtau.browser.page.PageElementValue
2020
import org.testingisdocumenting.webtau.browser.page.path.ElementPath
2121
import org.testingisdocumenting.webtau.browser.page.path.GenericPageElement
2222
import org.junit.Test
2323

24-
class ElementValueCompareToHandlerTest {
24+
class PageElementValueCompareToHandlerTest {
2525
def pageElement = new GenericPageElement(null, null, ElementPath.css("#id"))
2626

2727
@Test
2828
void "automatically converts text to a number if the expected value is a number"() {
29-
def elementValue = new ElementValue(pageElement, "element", { -> "100.6543"})
29+
def elementValue = new PageElementValue(pageElement, "element", { -> "100.6543"})
3030
elementValue.should == 100.6543
3131
}
3232
}

0 commit comments

Comments
 (0)