源附件不包含Throwables.class文件的源

时间:2014-12-25 13:39:58

标签: java eclipse

我试图在Eclipse中运行以下代码但得到此异常:

  

源附件不包含Throwables.class文件的源。

我尝试更改所需jar的路径,但无效。

    package automationFramework;

    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.*;

    import org.openqa.selenium.firefox.FirefoxDriver;

public class FirstTestCase {
private static WebDriver driver = null;
public static void main(String[] args) {
    // TODO Auto-generated method stub
    // Create a new instance of the Firefox driver

    driver = new FirefoxDriver();

    //Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //Launch the Online Store Website

    driver.get("http://www.store.demoqa.com");

    // Find the element that's ID attribute is 'account'(My Account)

    driver.findElement(By.xpath(".//*[@id='account']/a")).click();

    // Find the element that's ID attribute is 'log' (Username)

    // Enter Username on the element found by above desc.

    driver.findElement(By.id("log")).sendKeys("testuser_1");

    // Find the element that's ID attribute is 'pwd' (Password)

    // Enter Password on the element found by the above desc.

    driver.findElement(By.id("pwd")).sendKeys("Test@123");

    // Now submit the form. WebDriver will find the form for us from the element

    driver.findElement(By.id("login")).click();

    // Print a Log In message to the screen

    System.out.println(" Login Successfully, now it is the time to Log Off buddy.");

    // Find the element that's ID attribute is 'account_logout' (Log Out)

    driver.findElement (By.xpath(".//*[@id='account_logout']/a")).click();

    // Close the driver

    driver.quit();

        }

}

2 个答案:

答案 0 :(得分:10)

看起来您还没有向Eclipse展示Java库的源代码。应该有一个按钮来搜索它,在JDK文件中,应该有一个src.zip文件。

答案 1 :(得分:0)

这意味着它无法找到抛出包含的库中的throwable异常。您需要导入throwable java类