Skip to content

Instantly share code, notes, and snippets.

@masayuki5160
Last active December 21, 2015 08:59
Show Gist options
  • Save masayuki5160/6282300 to your computer and use it in GitHub Desktop.
Save masayuki5160/6282300 to your computer and use it in GitHub Desktop.
参考サイトのまんま。 JavaScriptのクリックイベントまでしてくれる。 まだよくわかってないけど参考になるソースなのでメモ。 http://blog.asial.co.jp/1180
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
public class Test {
public static void main(String[] args) {
RemoteWebDriver driver = new FirefoxDriver();
driver.get("http://www.asial.co.jp");
sleep(1000);
WebElement element = driver.findElement(By.cssSelector("ul.flex-direction-nav a.prev"));
for (int i=0; i<5; i++) {
driver.executeScript("arguments[0].click();", element);
sleep(3000);
}
//driver.quit();
}
private static void sleep(int microtime) {
try {
Thread.sleep(microtime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment