Skip to content

Commit fcb4a33

Browse files
Sandeep4odeskpivovarit
authored andcommitted
Updating the Selenium version (eugenp#779)
1 parent 5e46e92 commit fcb4a33

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎selenium-junit-testng/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<dependency>
5454
<groupId>org.seleniumhq.selenium</groupId>
5555
<artifactId>selenium-java</artifactId>
56-
<version>2.53.1</version>
56+
<version>3.0.1</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>junit</groupId>

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SeleniumExample {
1515
private String url = "http://www.baeldung.com/";
1616

1717
public SeleniumExample() {
18+
System.setProperty("webdriver.firefox.marionette", "C:\\selenium\\geckodriver.exe");
1819
webDriver = new FirefoxDriver();
1920
webDriver.manage().window().maximize();
2021
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
@@ -29,16 +30,20 @@ public String getTitle() {
2930
return webDriver.getTitle();
3031
}
3132

32-
public void getAboutBaeldungPage() throws Exception {
33+
public void getAboutBaeldungPage() {
3334
closeOverlay();
3435
clickAboutLink();
3536
clickAboutUsLink();
3637
}
3738

38-
private void closeOverlay() throws Exception {
39+
private void closeOverlay() {
3940
List<WebElement> webElementList = webDriver.findElements(By.tagName("a"));
40-
if (webElementList != null && !webElementList.isEmpty() && webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().isPresent()) {
41-
webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().orElseThrow(NoSuchElementException::new).click();
41+
try {
42+
if (webElementList != null && !webElementList.isEmpty()) {
43+
webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().orElseThrow(NoSuchElementException::new).click();
44+
}
45+
} catch (NoSuchElementException exception) {
46+
exception.printStackTrace();
4247
}
4348
}
4449

0 commit comments

Comments
 (0)