New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenide support for PageObjects without @FindBy annotations #443

Merged
merged 3 commits into from Dec 23, 2016

Conversation

Projects
None yet
4 participants
@SergeyPirogov
Collaborator

SergeyPirogov commented Dec 21, 2016

This PR fixes problem with initialization PageObjects that have SelenideElements declared as Class fields. See example below:

class StartPage{
private SelenideElement startPage = $("#start-page");
}

Before fix, if we use Selenide methods open("url",Class) or page(class) Selenide ignored field initialization and tried to find element by ID or Name of class field.

@asolntsev asolntsev merged commit fa4caf8 into selenide:master Dec 23, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

asolntsev added a commit that referenced this pull request Dec 25, 2016

@asolntsev

This comment has been minimized.

Show comment
Hide comment
@asolntsev

asolntsev Dec 25, 2016

Contributor

@SergeyPirogov Next time please add tests too!
See 8bc9f0c

Contributor

asolntsev commented Dec 25, 2016

@SergeyPirogov Next time please add tests too!
See 8bc9f0c

@SergeyPirogov

This comment has been minimized.

Show comment
Hide comment
@SergeyPirogov

SergeyPirogov Dec 26, 2016

Collaborator

@asolntsev I had tests included in pull requests

Collaborator

SergeyPirogov commented Dec 26, 2016

@asolntsev I had tests included in pull requests

@asolntsev

This comment has been minimized.

Show comment
Hide comment
@asolntsev

asolntsev Jan 26, 2017

Contributor

@SergeyPirogov Thank you! We recently released Selenide 4.2.1 that contains this improvement.

Contributor

asolntsev commented Jan 26, 2017

@SergeyPirogov Thank you! We recently released Selenide 4.2.1 that contains this improvement.

@CaBocuk

This comment has been minimized.

Show comment
Hide comment
@CaBocuk

CaBocuk Oct 6, 2017

Selenide 4.7.1.
It seems not working in case if we have SelenideElement inside ElementsContainer which is declared in some page object class

For example I have the following code:

public class AdminHeader extends ElementsContainer {
	private SelenideElement newEventButton = $(".new-event-button");
}
public class AdminHomePage {
	@FindBy(css=".navigation-header")
	AdminHeader header;
}

And after calling page(AdminHomePage.class) I receive following error

Element not found {by id or name "newEventButton"} 
Expected: visible
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"newEventButton"} 	
at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:31) 	
at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:82) 	
at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:59) 	
at com.codeborne.selenide.commands.Should.should(Should.java:35) 	
at com.codeborne.selenide.commands.Should.execute(Should.java:29) 	
at com.codeborne.selenide.commands.Should.execute(Should.java:12) 	
at com.codeborne.selenide.commands.Commands.execute(Commands.java:143) 	
at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:87) 	
at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:63) 	
at com.sun.proxy.$Proxy29.shouldBe(Unknown Source) 	
at com.epam.events.admin.steps.ContainsAdminHeaderSteps.openNewEventPopup(ContainsAdminHeaderSteps.java:11) ............
--

CaBocuk commented Oct 6, 2017

Selenide 4.7.1.
It seems not working in case if we have SelenideElement inside ElementsContainer which is declared in some page object class

For example I have the following code:

public class AdminHeader extends ElementsContainer {
	private SelenideElement newEventButton = $(".new-event-button");
}
public class AdminHomePage {
	@FindBy(css=".navigation-header")
	AdminHeader header;
}

And after calling page(AdminHomePage.class) I receive following error

Element not found {by id or name "newEventButton"} 
Expected: visible
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"newEventButton"} 	
at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:31) 	
at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:82) 	
at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:59) 	
at com.codeborne.selenide.commands.Should.should(Should.java:35) 	
at com.codeborne.selenide.commands.Should.execute(Should.java:29) 	
at com.codeborne.selenide.commands.Should.execute(Should.java:12) 	
at com.codeborne.selenide.commands.Commands.execute(Commands.java:143) 	
at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:87) 	
at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:63) 	
at com.sun.proxy.$Proxy29.shouldBe(Unknown Source) 	
at com.epam.events.admin.steps.ContainsAdminHeaderSteps.openNewEventPopup(ContainsAdminHeaderSteps.java:11) ............
--
@BorisOsipov

This comment has been minimized.

Show comment
Hide comment
@BorisOsipov

BorisOsipov Oct 6, 2017

Member

@CaBocuk It works in selenide tests https://github.com/codeborne/selenide/blob/fa4caf8dbe527533ab69e222022e0a5128311de6/src/test/java/integration/PageObjectTest.java

If you ran into issue create reproducible example and report it https://github.com/codeborne/selenide/issues/new

Do not write comments to closed PR's.
We can miss such messages.

Member

BorisOsipov commented Oct 6, 2017

@CaBocuk It works in selenide tests https://github.com/codeborne/selenide/blob/fa4caf8dbe527533ab69e222022e0a5128311de6/src/test/java/integration/PageObjectTest.java

If you ran into issue create reproducible example and report it https://github.com/codeborne/selenide/issues/new

Do not write comments to closed PR's.
We can miss such messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment