|
22 | 22 | import static org.junit.Assert.assertThat;
|
23 | 23 |
|
24 | 24 | import org.junit.Test;
|
| 25 | +import org.openqa.selenium.By; |
25 | 26 | import org.openqa.selenium.JavascriptExecutor;
|
| 27 | +import org.openqa.selenium.StubDriver; |
| 28 | +import org.openqa.selenium.WebDriver; |
26 | 29 | import org.openqa.selenium.WebElement;
|
| 30 | +import org.openqa.selenium.remote.RemoteWebElement; |
| 31 | +import org.openqa.selenium.remote.internal.WebElementToJsonConverter; |
27 | 32 | import org.openqa.selenium.support.CacheLookup;
|
28 | 33 | import org.openqa.selenium.support.FindBy;
|
29 | 34 | import org.openqa.selenium.support.PageFactory;
|
@@ -61,6 +66,32 @@ public void canListDecoratedElements() {
|
61 | 66 | }
|
62 | 67 | }
|
63 | 68 |
|
| 69 | + @Test |
| 70 | + public void testDecoratedElementsShouldBeUnwrapped() { |
| 71 | + final RemoteWebElement element = new RemoteWebElement(); |
| 72 | + element.setId("foo"); |
| 73 | + |
| 74 | + WebDriver driver = new StubDriver() { |
| 75 | + @Override |
| 76 | + public WebElement findElement(By by) { |
| 77 | + return element; |
| 78 | + } |
| 79 | + }; |
| 80 | + |
| 81 | + PublicPage page = new PublicPage(); |
| 82 | + PageFactory.initElements(driver, page); |
| 83 | + |
| 84 | + Object seen = new WebElementToJsonConverter().apply(page.element); |
| 85 | + Object expected = new WebElementToJsonConverter().apply(element); |
| 86 | + |
| 87 | + assertEquals(expected, seen); |
| 88 | + } |
| 89 | + |
| 90 | + |
| 91 | + public class PublicPage { |
| 92 | + public WebElement element; |
| 93 | + } |
| 94 | + |
64 | 95 | public static class Page {
|
65 | 96 | @FindBy(name = "someForm")
|
66 | 97 | WebElement formElement;
|
|
0 commit comments