-
-
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
Improve UI test coverage #2048
Changes from 10 commits
ecf102f
6cb4be5
f2ff452
5c450f9
f88b290
169dcf5
1f91673
c365391
47f455c
044949f
b9d39ba
4552535
e9adba8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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(); | ||
} | ||
} |
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")); | ||
} | ||
} |
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")); | ||
} | ||
} | ||
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(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add check for empty list to prevent IndexOutOfBoundsException. The public void pressRandomLetter() {
List<WebElement> links = driver.findElements(By.className("editLink"));
+ if (links.isEmpty()) {
+ throw new IllegalStateException("No letter elements found with class 'editLink' on the page");
+ }
int randomIndex = (int)(Math.random() * links.size());
WebElement randomLink = links.get(randomIndex);
randomLink.click();
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public void pressCreateButton() { | ||||||||||||||||||||||||||||||||
WebElement button = driver.findElement(By.id("createButton")); | ||||||||||||||||||||||||||||||||
button.click(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
package selenium.content.letter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 LetterTest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 testRandomLetterEditPage() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.info("testRandomLetterEditPage"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
MainContentPage mainContentPage = new MainContentPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
mainContentPage.pressLetterListLink(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterListPage letterListPage = new LetterListPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
letterListPage.pressRandomLetter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterEditPage letterEditPage = new LetterEditPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+45
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add assertions to validate test outcomes. The test method navigates to pages but doesn't verify any expected outcomes. Consider adding assertions to validate that the page was loaded correctly or that specific elements are present. @Test
public void testRandomLetterEditPage() {
log.info("testRandomLetterEditPage");
MainContentPage mainContentPage = new MainContentPage(driver);
mainContentPage.pressLetterListLink();
LetterListPage letterListPage = new LetterListPage(driver);
letterListPage.pressRandomLetter();
LetterEditPage letterEditPage = new LetterEditPage(driver);
+ // Verify that we're on the edit page
+ assertTrue(letterEditPage.isPageLoaded(), "Letter edit page failed to load");
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
public void testLetterCreatPage() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.info("testLetterCreatePage"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
MainContentPage mainContentPage = new MainContentPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
mainContentPage.pressLetterListLink(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterListPage letterListPage = new LetterListPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
letterListPage.pressCreateButton(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterCreatePage letterCreatePage = new LetterCreatePage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add assertions to validate test outcomes. The test method navigates to the letter creation page but doesn't verify any expected outcomes. Consider adding assertions to validate that the page was loaded correctly. @Test
-public void testLetterCreatPage() {
+public void testLetterCreatePage() {
log.info("testLetterCreatePage");
MainContentPage mainContentPage = new MainContentPage(driver);
mainContentPage.pressLetterListLink();
LetterListPage letterListPage = new LetterListPage(driver);
letterListPage.pressCreateButton();
LetterCreatePage letterCreatePage = new LetterCreatePage(driver);
+ // Verify that we're on the create page
+ assertTrue(letterCreatePage.isPageLoaded(), "Letter create page failed to load");
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package selenium.content.letter_sound; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class LetterSoundCreatePage { | ||
|
||
private WebDriver driver; | ||
|
||
public LetterSoundCreatePage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("letterSoundCreatePage")); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package selenium.content.letter_sound; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class LetterSoundEditPage { | ||
|
||
private WebDriver driver; | ||
|
||
public LetterSoundEditPage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("letterSoundEditPage")); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,30 @@ | ||||||||||||||||||||||||||||||||
package selenium.content.letter_sound; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import org.openqa.selenium.By; | ||||||||||||||||||||||||||||||||
import org.openqa.selenium.WebDriver; | ||||||||||||||||||||||||||||||||
import org.openqa.selenium.WebElement; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public class LetterSoundListPage { | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
private WebDriver driver; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public LetterSoundListPage(WebDriver driver) { | ||||||||||||||||||||||||||||||||
this.driver = driver; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
driver.findElement(By.id("letterSoundListPage")); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public void pressRandomLetterSound() { | ||||||||||||||||||||||||||||||||
List<WebElement> links = driver.findElements(By.className("editLink")); | ||||||||||||||||||||||||||||||||
int randomIndex = (int)(Math.random() * links.size()); | ||||||||||||||||||||||||||||||||
WebElement randomLink = links.get(randomIndex); | ||||||||||||||||||||||||||||||||
randomLink.click(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for empty list of letter sounds. The method should check if the list is empty before trying to select a random element. public void pressRandomLetterSound() {
List<WebElement> links = driver.findElements(By.className("editLink"));
+ if (links.isEmpty()) {
+ throw new IllegalStateException("No letter sound elements found with class 'editLink' on the page");
+ }
int randomIndex = (int)(Math.random() * links.size());
WebElement randomLink = links.get(randomIndex);
randomLink.click();
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public void pressCreateButton() { | ||||||||||||||||||||||||||||||||
WebElement button = driver.findElement(By.id("createButton")); | ||||||||||||||||||||||||||||||||
button.click(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
package selenium.content.letter_sound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 LetterSoundTest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 testRandomLetterSoundEditPage() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.info("testRandomLetterSoundEditPage"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
MainContentPage mainContentPage = new MainContentPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
mainContentPage.pressLetterSoundListLink(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterSoundListPage letterSoundListPage = new LetterSoundListPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
letterSoundListPage.pressRandomLetterSound(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterSoundEditPage letterSoundEditPage = new LetterSoundEditPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+45
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add assertions to validate test outcomes. The test method navigates to pages but doesn't verify any expected outcomes. Consider adding assertions to validate that the page was loaded correctly or that specific elements are present. @Test
public void testRandomLetterSoundEditPage() {
log.info("testRandomLetterSoundEditPage");
MainContentPage mainContentPage = new MainContentPage(driver);
mainContentPage.pressLetterSoundListLink();
LetterSoundListPage letterSoundListPage = new LetterSoundListPage(driver);
letterSoundListPage.pressRandomLetterSound();
LetterSoundEditPage letterSoundEditPage = new LetterSoundEditPage(driver);
+ // Verify that we're on the edit page
+ assertTrue(letterSoundEditPage.isPageLoaded(), "Letter sound edit page failed to load");
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
public void testLetterSoundCreatPage() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.info("testLetterSoundCreatePage"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
MainContentPage mainContentPage = new MainContentPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
mainContentPage.pressLetterSoundListLink(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterSoundListPage letterSoundListPage = new LetterSoundListPage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
letterSoundListPage.pressCreateButton(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
LetterSoundCreatePage letterSoundCreatePage = new LetterSoundCreatePage(driver); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add assertions to validate test outcomes. The test method navigates to the letter sound creation page but doesn't verify any expected outcomes. Consider adding assertions to validate that the page was loaded correctly. @Test
-public void testLetterSoundCreatPage() {
+public void testLetterSoundCreatePage() {
log.info("testLetterSoundCreatePage");
MainContentPage mainContentPage = new MainContentPage(driver);
mainContentPage.pressLetterSoundListLink();
LetterSoundListPage letterSoundListPage = new LetterSoundListPage(driver);
letterSoundListPage.pressCreateButton();
LetterSoundCreatePage letterSoundCreatePage = new LetterSoundCreatePage(driver);
+ // Verify that we're on the create page
+ assertTrue(letterSoundCreatePage.isPageLoaded(), "Letter sound create page failed to load");
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package selenium.content.sound; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class SoundCreatePage { | ||
|
||
private WebDriver driver; | ||
|
||
public SoundCreatePage(WebDriver driver) { | ||
this.driver = driver; | ||
|
||
driver.findElement(By.id("soundCreatePage")); | ||
} | ||
} |
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: