Java tutorial
/* * Copyright 2016 Karl Bennett * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cucumber.scratch.maven.react; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.opera.OperaDriver; import org.openqa.selenium.safari.SafariDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import shiver.me.timbers.waiting.WaiterAspect; import java.util.concurrent.TimeUnit; import static java.lang.String.format; @Configuration public class SeleniumConfiguration { @Bean(destroyMethod = "quit") public WebDriver driver(@Value("${web.driver:chrome}") String webDriver) { if ("chrome".equals(webDriver)) { return new ChromeDriver(); } if ("firefox".equals(webDriver)) { return new FirefoxDriver(); } if ("ie".equals(webDriver)) { return new InternetExplorerDriver(); } if ("safari".equals(webDriver)) { return new SafariDriver(); } if ("opera".equals(webDriver)) { return new OperaDriver(); } throw new IllegalArgumentException(format("Web driver %s not supported.", webDriver)); } @Bean public WaiterAspect waiterAspect() { return new WaiterAspect(); } @Autowired public void configureWebDriver(WebDriver driver) { driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS); } }