Skip to content

Commit a601956

Browse files
authored
Remove try-catch from Test classes (eugenp#798)
* Updating the Selenium version * Remove try-catch from Test classes * Making changes in Maven Profile for Test Case Failure * Making changes in Maven Profile for Test Case Failure
2 parents 62bcec6 + 9da09a5 commit a601956

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

‎selenium-junit-testng/pom.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<include>**/*UnitTest.java</include>
2626
</includes>
2727
<systemPropertyVariables></systemPropertyVariables>
28+
<testFailureIgnore>false</testFailureIgnore>
2829
</configuration>
2930
</plugin>
3031
</plugins>
@@ -42,6 +43,7 @@
4243
<includes>
4344
<include>**/*LiveTest.java</include>
4445
</includes>
46+
<testFailureIgnore>false</testFailureIgnore>
4547
</configuration>
4648
</plugin>
4749
</plugins>

‎selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ private void clickAboutUsLink() {
5656
}
5757

5858
public boolean isAuthorInformationAvailable() {
59-
return webDriver.findElement(By.xpath("//*[contains(text(), 'Eugen – an engineer')]")).isDisplayed();
59+
return webDriver.findElement(By.xpath("//*[contains(text(), 'an engineer with a passion for teaching and building stuff on the web')]")).isDisplayed();
6060
}
6161
}

‎selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumWithJUnitLiveTest.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ public static void tearDown() {
2626

2727
@Test
2828
public void whenAboutBaeldungIsLoaded_thenAboutEugenIsMentionedOnPage() {
29-
try {
3029
seleniumExample.getAboutBaeldungPage();
3130
String actualTitle = seleniumExample.getTitle();
3231
assertNotNull(actualTitle);
3332
assertEquals(actualTitle, expecteTilteAboutBaeldungPage);
3433
assertTrue(seleniumExample.isAuthorInformationAvailable());
35-
} catch (Exception exception) {
36-
exception.printStackTrace();
37-
seleniumExample.closeWindow();
38-
}
3934
}
4035

4136
}

‎selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/SeleniumWithTestNGLiveTest.java‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,10 @@ public void tearDown() {
2626

2727
@Test
2828
public void whenAboutBaeldungIsLoaded_thenAboutEugenIsMentionedOnPage() {
29-
try {
30-
seleniumExample.getAboutBaeldungPage();
31-
String actualTitle = seleniumExample.getTitle();
32-
assertNotNull(actualTitle);
33-
assertEquals(actualTitle, expecteTilteAboutBaeldungPage);
34-
assertTrue(seleniumExample.isAuthorInformationAvailable());
35-
} catch (Exception exception) {
36-
exception.printStackTrace();
37-
seleniumExample.closeWindow();
38-
}
29+
seleniumExample.getAboutBaeldungPage();
30+
String actualTitle = seleniumExample.getTitle();
31+
assertNotNull(actualTitle);
32+
assertEquals(actualTitle, expecteTilteAboutBaeldungPage);
33+
assertTrue(seleniumExample.isAuthorInformationAvailable());
3934
}
4035
}

0 commit comments

Comments
 (0)