Updating the Selenium version (#779)

This commit is contained in:
Sandeep4odesk 2016-10-29 15:09:24 +05:30 committed by Grzegorz Piwowarek
parent 5e46e9278c
commit fcb4a33e3a
2 changed files with 10 additions and 5 deletions

View File

@ -53,7 +53,7 @@
<dependency> <dependency>
<groupId>org.seleniumhq.selenium</groupId> <groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId> <artifactId>selenium-java</artifactId>
<version>2.53.1</version> <version>3.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -15,6 +15,7 @@ public class SeleniumExample {
private String url = "http://www.baeldung.com/"; private String url = "http://www.baeldung.com/";
public SeleniumExample() { public SeleniumExample() {
System.setProperty("webdriver.firefox.marionette", "C:\\selenium\\geckodriver.exe");
webDriver = new FirefoxDriver(); webDriver = new FirefoxDriver();
webDriver.manage().window().maximize(); webDriver.manage().window().maximize();
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
@ -29,16 +30,20 @@ public class SeleniumExample {
return webDriver.getTitle(); return webDriver.getTitle();
} }
public void getAboutBaeldungPage() throws Exception { public void getAboutBaeldungPage() {
closeOverlay(); closeOverlay();
clickAboutLink(); clickAboutLink();
clickAboutUsLink(); clickAboutUsLink();
} }
private void closeOverlay() throws Exception { private void closeOverlay() {
List<WebElement> webElementList = webDriver.findElements(By.tagName("a")); List<WebElement> webElementList = webDriver.findElements(By.tagName("a"));
if (webElementList != null && !webElementList.isEmpty() && webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().isPresent()) { try {
webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().orElseThrow(NoSuchElementException::new).click(); if (webElementList != null && !webElementList.isEmpty()) {
webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().orElseThrow(NoSuchElementException::new).click();
}
} catch (NoSuchElementException exception) {
exception.printStackTrace();
} }
} }