2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WebDriverのサンプル(古いかも)

2
Posted at

自サイトより転載

sample.java
//ドライバー。どっかでインスタンス化しておくこと。
private InternetExplorerDriver driver = null;

~~~省略~~~
/** 
 * アラートを閉じる。alertでもconfirmでも使えるが、 
 * beforeUnloadの際の確認ダイアログに対しては無効。 
 */
private void alertClose(){
     //キャンセルの場合はこっち     
     driver.switchTo().alert().dismiss();     
     //OKの場合はこっち     
     //driver.switchTo().alert.accept();
}
/**
 *
 指定された要素でエンターキーを押す。
 * @param element
 */
private void pressEnter(WebElement element){
     //keydown/keyup出来るキーはSHIFT、ALT、CONTROLのみ。
     element.click();
    driver.getKeyboard().pressKey(Keys.ENTER);
}
/**
 * ESCキーを押す。
 */
private void pressEscape(){
     driver.getKeyboard().pressKey(Keys.ESCAPE);
}

/**
 * 指定した要素をダブルクリックする。
 * @param element
 */
private void dblClick(WebElement element){
     DoubleClickAction dblClick = 
       new DoubleClickAction(driver.getMouse(), (Locatable) element);
     dblClick.perform();
}

//ajaxで要素が出てくるまでの待ち合わせ時間を設定
driver.manage().timeouts().implicitlyWait(90,TimeUnit.SECONDS);
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?