Skip to content
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

Assertions #173

Open
wants to merge 12 commits into
base: assertions
Choose a base branch
from
Open

Assertions #173

wants to merge 12 commits into from

Conversation

kealant
Copy link

@kealant kealant commented Aug 28, 2017

Short description of what this resolves:

Adds the following fluent assertions to graphene:
-isNot() a method to negate the following assertion
-hasText(String expectedText) asserts the expectedText is equal to the text of the WebElement
-hasChild() asserts that the WebElement has child elements
-hasParent() asserts that the WebElement has parent nodes
-isDisplayed() asserts that the WebElement is displayed on the page i.e. not hidden
-isSelected() asserts the chosen WebElement is selected by the driver
-isChosenD(Select dropdown) the same as is selected but only works for dropboxes, asserting that the chosen dropbox is selected by the driver. The dropdown must be supplied to the method
-containsText(String expectedText) asserts that the text of an input box is equal to expectedText
-isEmpty() asserts that the given input box is empty
-isTypeOf(String expectedType) asserts that the type attribute of the WebElement is equal to expectedType
-hasCssClass(String expectedClass) asserts that the given WebElement's css class is the same as the supplied expectedClass
-isFocused() asserts that the given WebElement is in focus
-isEnabled() asserts that the WebElement is enabled i.e. not a disabled text input form etc.
-textMatchesRegex(String regex) asserts the supplied regex matches the text of the given WebElement
-caseInsensitiveMatching(String match) asserts the supplied string match is equal to the text of the WebElement regardless of case
-subStringMatching(String match) asserts the supplied substring matches the text of the given WebElement
Each method can be used by calling assertThat(WebElement) and calling subsequent assertions after e.g:
assertThat(inputForm).isNot().isEmpty().containsText("not empty")

Changes proposed in this pull request:

Fixes: #

@bartoszmajsak
Copy link
Member

bartoszmajsak commented Sep 4, 2017

@kealant could you provide a description of this PR? We could use it as documentation together with the merged code.

We are also missing JavaDoc for the assertions. This is useful for programmers using our API.


import org.apache.commons.io.input.ReversedLinesFileReader;

public class GrapheneVerify extends Actions {
Copy link
Member

Choose a reason for hiding this comment

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

What is this code doing here? If it's dead no reason to have it :)

public WebElementAssert hasChild(){
if (this.negated) {
assertThat(this.actual.findElements(ByJQuery.selector("*"))).asList().size().isEqualTo(0);
this.negated = false;
Copy link
Member

Choose a reason for hiding this comment

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

If the about fails this line would never be reached. Why are we doing this assignment in the first place?


import org.jboss.arquillian.graphene.guard.RequestGuardFactory;

public class EventHandler implements WebDriverEventListener {
Copy link
Member

Choose a reason for hiding this comment

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

What was the purpose of it?

Copy link
Author

Choose a reason for hiding this comment

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

To track the following interactions: clicking, sending keys to an input box and clearing an input box. Write them to static storage and check it when calling .verify() on an actions object, confirming the above actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants