2017-07-28 4 views
-3
package com.confirm; 
    import org.openqa.selenium.Alert; 
    import org.openqa.selenium.By; 
    import org.openqa.selenium.WebDriver; 
    import org.openqa.selenium.firefox.FirefoxDriver; 
    import org.testng.annotations.Test; 
    public class ConfirmDemo { 
    WebDriver driver = new FirefoxDriver(); 
    @Test 
    public void ExampleForConfrim() throws InterruptedException { 
    driver.manage().window().maximize(); 
    driver.get("file:///C:/confirm.html"); 
    Thread.sleep(2000); 
    driver.findElement(By.xpath("//button[@onClick='confirmFunction()']")); 
    Alert alert=driver.switchTo().alert(); 
    System.out.println(alert.getText()); 
    alert.dismiss(); 
    driver.close(); 
} 
} 

これは初めてのセレンプログラムです。私はこのコードをeclipseに入力して、セレクション用の外部jarファイルも追加します。セレンはエクリプスでは実行できません

選択は起動できず、最近の起動はありません。

これを解決するには?

答えて

関連する問題