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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27647709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:46:40  来源:igfitidea点击:

the source attachment does not contain the source for the file Throwables.class

javaeclipse

提问by Ahmed Sayed

I'm trying to run the following code in Eclipse but get this exception:

我正在尝试在 Eclipse 中运行以下代码,但出现此异常:

Source Attachment does not contain the source for the file Throwables.class.

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

I tried to change the path of the required jar, but is not working.

我试图更改所需 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();

        }

}

采纳答案by FlyingPiMonster

It looks like you haven't showed Eclipse the source code for the Java library. There should be a button to search for it, and in the JDK files, there should be a src.zipfile.

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

回答by Prasad Pathak

It means that the it is not able to find a throwable exception to throw in your included library. You need to import the throwable java class

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