はじめに
友人のsyobochimが勉強会やるということで、裏方(運営)的なポジションで参加させていただきました。
しょぼちむにデータモデル設計について教えてくださいの会 #syoboben
勉強会の様子はtogetterで雰囲気を感じていただければと思います。
ゆるふわと見せかけてガチ勢が来たしょぼちむ勉強会
会場はドリコムさん。こんなかんじ。エントランスにはベイマックスがいました。
以下、発表を順に振り返ってみます。。。。
#IE driver.ie.exe=C:\\IEDriverServer.exe driver.ie.key=webdriver.ie.driver driver.ie.driverclass=org.openqa.selenium.ie.InternetExplorerDriver #Chrome driver.chrome.exe=C:\\chromedriver.exe driver.chrome.key=webdriver.chrome.driver driver.chrome.driverclass=org.openqa.selenium.chrome.ChromeDriver #Firefox driver.ff.driverclass=org.openqa.selenium.firefox.FirefoxDriver
public class BrowserRule implements MethodRule { private final String[] paths; public BrowserRule(String... paths) { this.paths = paths; } public Statement apply(final Statement base, FrameworkMethod method, Object target) { return new Statement() { @Override public void evaluate() throws Throwable { for (String path : paths) { ModeContext.setBrowserName(path); base.evaluate(); } } }; } }
public class ModeContext { private static String browserName; private ModeContext () {} public static void setBrowserName(String name) { browserName = name; } public static String getBrowserName() { return browserName; } }
public class HogeHogeTest { @Rule public BrowserRule browserRule = new BrowserRule("ie"); // ie //public BrowserRule browserRule = new BrowserRule("chrome"); chrome //public BrowserRule browserRule = new BrowserRule("ff"); firefox //public BrowserRule browserRule = new BrowserRule("ie","chrome","ff"); これもできる public WebDriver driver; @Before public void startUpClass() throws Exception { Properties prop = loadProperties(); final String browser = ModeContext.getBrowserName(); final String[] PROP_KEYS = new String[] { "driver." + browser + ".exe", "driver." + browser + ".key", "driver." + browser + ".driverclass"}; if(!browser.equals("ff")) { Path path = Paths.get(prop.getProperty(PROP_KEYS[0])); System.setProperty(prop.getProperty(PROP_KEYS[1]), path.toAbsolutePath().toString()); } Class<?> clazz = Class.forName(prop.getProperty(PROP_KEYS[2])); driver = (WebDriver) clazz.newInstance(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(3, TimeUnit.MINUTES); driver.get("http://localhost:8080/hogehoge"); } private Properties loadProperties() { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Properties prop = new Properties(); prop.load(loader.getResourceAsStream("DriverSetting.properties")); return prop; } catch (IOException e) { throw new IllegalStateException("failed load DriverSetting.properties ", e); } } }