forked from serenity-bdd/serenity-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved reporting for Enter and Type tasks
- Loading branch information
Showing
15 changed files
with
105 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ay-webdriver/src/main/java/net/serenitybdd/screenplay/actions/type/RenderEnteredText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.serenitybdd.screenplay.actions.type; | ||
|
||
import net.serenitybdd.core.collect.NewList; | ||
import net.serenitybdd.core.strings.Joiner; | ||
import net.serenitybdd.screenplay.actions.KeyNames; | ||
import org.openqa.selenium.Keys; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Arrays.stream; | ||
|
||
public class RenderEnteredText { | ||
|
||
private static final String ENTER_KEYS_INTRO_TEXT = " then hits "; | ||
|
||
public static String getFollowedByKeysDescriptionFor(List<Keys> keys) { | ||
if (keys.isEmpty()) { | ||
return ""; | ||
} | ||
if (keys.size() == 1) { | ||
return ENTER_KEYS_INTRO_TEXT + KeyNames.of(keys); | ||
} | ||
if (keys.size() == 2) { | ||
return ENTER_KEYS_INTRO_TEXT + Joiner.on(" and ").join(KeyNames.of(keys)); | ||
} | ||
|
||
String allButLastTwo = Joiner.on(", ").join(KeyNames.allButLastTwo(keys)); | ||
String lastTwoKeys = Joiner.on(" and ").join(KeyNames.lastTwoOf(keys)); | ||
String allKeys = Joiner.on(", ").join(NewList.of(allButLastTwo, lastTwoKeys)); | ||
|
||
return ENTER_KEYS_INTRO_TEXT + allKeys; | ||
} | ||
|
||
|
||
public static String getTextAsStringFor(CharSequence... theText) { | ||
|
||
return stream(theText).map( | ||
textValue -> (textValue instanceof Keys) ? ((Keys) textValue).name() : "'" + textValue.toString() + "'" | ||
).collect(Collectors.joining(",")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters