2017年頃、Selenium2を使ったことがあります。
いろいろハマりました。。。特にIE。
ハマったときのメモを見ていたら、最近はどうなっているのだろうと思い、Selenium3とFluentleniumを触ってみました。
触ったといっても、ただブラウザを起動しただけです。
環境
ソース
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.13.0'
// https://mvnrepository.com/artifact/org.fluentlenium/fluentlenium-core
compile group: 'org.fluentlenium', name: 'fluentlenium-core', version: '3.6.0'
// https://mvnrepository.com/artifact/org.fluentlenium/fluentlenium-junit
compile group: 'org.fluentlenium', name: 'fluentlenium-junit', version: '3.6.0'
}
public class Main {
public static void main(String[] args) throws Exception {
System.out.println("hello");
System.setProperty("webdriver.chromedriver.driver", "/MyProgram/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.co.jp/");
driver.findElement(By.id("lst-ib")).sendKeys("Selenium3");
driver.findElement(By.name("btnK")).click();
driver.quit();
}
}
@Wait
public class DuckDuckGoTest extends FluentTest {
@Override
public WebDriver newWebDriver() {
System.setProperty("webdriver.chromedriver.driver", "/MyProgram/chromedriver.exe");
WebDriver driver = new ChromeDriver();
return driver;
}
@Test
public void titleOfDuckDuckGoShouldContainSearchQueryName() {
goTo("https://duckduckgo.com/");
$("#search_form_input_homepage").fill().with("FluentLenium");
$("#search_button_homepage").submit();
$("#search_button_homepage").attributes("");
}
}
感想
- Seleniumとりあえず動いた
- Firefoxは動かなかった。ブラウザのバージョン。ブラウザのバージョンアップが速いので、環境構築周りが面倒だなと改めて思った。
- Selenium界隈の技術の進歩は速くて、ついていくのが大変だなー