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>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

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