-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Improve UI test coverage #2048
Merged
Merged
Improve UI test coverage #2048
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ecf102f
test: ui tests - letters
jo-elimu 6cb4be5
Merge branch 'main' into 2037-improve-ui-test-coverage
jo-elimu f2ff452
test: ui tests - sounds
jo-elimu 5c450f9
refactor: ui tests - letters
jo-elimu f88b290
Merge branch 'main' into 2037-improve-ui-test-coverage
jo-elimu 169dcf5
Update pom-dependency-tree.txt
jo-elimu 1f91673
refactor: ui tests - create page
jo-elimu c365391
test: ui tests - sounds
jo-elimu 47f455c
Merge branch 'main' into 2037-improve-ui-test-coverage
jo-elimu 044949f
test: ui tests - letter-sounds
jo-elimu b9d39ba
test: ui tests - numbers
jo-elimu 4552535
test: ui tests - words
jo-elimu e9adba8
test: ui tests - emojis
jo-elimu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package selenium.content; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public class MainContentPage { | ||
|
||
private WebDriver driver; | ||
|
||
public MainContentPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("mainContentPage")); | ||
} | ||
|
||
public void pressLetterListLink() { | ||
WebElement link = driver.findElement(By.id("letterListLink")); | ||
link.click(); | ||
} | ||
|
||
public void pressSoundListLink() { | ||
WebElement link = driver.findElement(By.id("soundListLink")); | ||
link.click(); | ||
} | ||
|
||
public void pressLetterSoundListLink() { | ||
WebElement link = driver.findElement(By.id("letterSoundListLink")); | ||
link.click(); | ||
} | ||
|
||
public void pressNumberListLink() { | ||
WebElement link = driver.findElement(By.id("numberListLink")); | ||
link.click(); | ||
} | ||
|
||
public void pressWordListLink() { | ||
WebElement link = driver.findElement(By.id("wordListLink")); | ||
link.click(); | ||
} | ||
|
||
public void pressEmojiListLink() { | ||
WebElement link = driver.findElement(By.id("emojiListLink")); | ||
link.click(); | ||
} | ||
} |
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,15 @@ | ||
package selenium.content.emoji; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class EmojiCreatePage { | ||
|
||
private WebDriver driver; | ||
|
||
public EmojiCreatePage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("emojiCreatePage")); | ||
} | ||
} |
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,15 @@ | ||
package selenium.content.emoji; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class EmojiEditPage { | ||
|
||
private WebDriver driver; | ||
|
||
public EmojiEditPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("emojiEditPage")); | ||
} | ||
} |
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,30 @@ | ||
package selenium.content.emoji; | ||
|
||
import java.util.List; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public class EmojiListPage { | ||
|
||
private WebDriver driver; | ||
|
||
public EmojiListPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("emojiListPage")); | ||
} | ||
|
||
public void pressRandomEmoji() { | ||
List<WebElement> links = driver.findElements(By.className("editLink")); | ||
int randomIndex = (int) (Math.random() * links.size()); | ||
WebElement randomLink = links.get(randomIndex); | ||
randomLink.click(); | ||
} | ||
|
||
public void pressCreateButton() { | ||
WebElement button = driver.findElement(By.id("createButton")); | ||
button.click(); | ||
} | ||
} |
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,70 @@ | ||
package selenium.content.emoji; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import selenium.content.MainContentPage; | ||
import selenium.util.DomainHelper; | ||
|
||
@Slf4j | ||
public class EmojiTest { | ||
|
||
private WebDriver driver; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
log.info("setUp"); | ||
|
||
ChromeOptions chromeOptions = new ChromeOptions(); | ||
|
||
// Read "headless" property set on the command line: | ||
// mvn clean verify -P regression-test-ui -D headless=true | ||
String headlessSystemProperty = System.getProperty("headless"); | ||
log.info("headlessSystemProperty: \"" + headlessSystemProperty + "\""); | ||
if ("true".equals(headlessSystemProperty)) { | ||
chromeOptions.addArguments("headless"); | ||
} | ||
|
||
driver = new ChromeDriver(chromeOptions); | ||
|
||
driver.get(DomainHelper.getBaseUrl() + "/content"); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
log.info("tearDown"); | ||
|
||
driver.quit(); | ||
} | ||
|
||
@Test | ||
public void testRandomEmojiEditPage() { | ||
log.info("testRandomEmojiEditPage"); | ||
|
||
MainContentPage mainContentPage = new MainContentPage(driver); | ||
mainContentPage.pressEmojiListLink(); | ||
|
||
EmojiListPage emojiListPage = new EmojiListPage(driver); | ||
emojiListPage.pressRandomEmoji(); | ||
|
||
EmojiEditPage emojiEditPage = new EmojiEditPage(driver); | ||
} | ||
|
||
@Test | ||
public void testEmojiCreatePage() { | ||
log.info("testEmojiCreatePage"); | ||
|
||
MainContentPage mainContentPage = new MainContentPage(driver); | ||
mainContentPage.pressEmojiListLink(); | ||
|
||
EmojiListPage emojiListPage = new EmojiListPage(driver); | ||
emojiListPage.pressCreateButton(); | ||
|
||
EmojiCreatePage emojiCreatePage = new EmojiCreatePage(driver); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/selenium/content/letter/LetterCreatePage.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,15 @@ | ||
package selenium.content.letter; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class LetterCreatePage { | ||
|
||
private WebDriver driver; | ||
|
||
public LetterCreatePage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("letterCreatePage")); | ||
} | ||
} |
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,15 @@ | ||
package selenium.content.letter; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class LetterEditPage { | ||
|
||
private WebDriver driver; | ||
|
||
public LetterEditPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("letterEditPage")); | ||
} | ||
} | ||
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,30 @@ | ||
package selenium.content.letter; | ||
|
||
import java.util.List; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public class LetterListPage { | ||
|
||
private WebDriver driver; | ||
|
||
public LetterListPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("letterListPage")); | ||
} | ||
|
||
public void pressRandomLetter() { | ||
List<WebElement> links = driver.findElements(By.className("editLink")); | ||
int randomIndex = (int) (Math.random() * links.size()); | ||
WebElement randomLink = links.get(randomIndex); | ||
randomLink.click(); | ||
} | ||
|
||
public void pressCreateButton() { | ||
WebElement button = driver.findElement(By.id("createButton")); | ||
button.click(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider implementing a base page object to reduce duplication across page classes.
I notice a pattern of similar code structure across the different page objects. Consider creating a base page class to reduce duplication and improve maintainability.
Here's a suggested approach using a base page class:
And create a base page class: