Java Edureka-在Selenium Web驱动程序中处理异常-无打印输出
我在自动化测试方面完全是个呆子,我正试图通过Youtube学习如何做到这一点 在这个来自Edureka的课程中,有一个例子,他们试图处理一个异常,在他们运行脚本后,系统在控制台中向他们显示一条我无法获取的消息Java Edureka-在Selenium Web驱动程序中处理异常-无打印输出,java,eclipse,selenium-webdriver,exception,selenium-chromedriver,Java,Eclipse,Selenium Webdriver,Exception,Selenium Chromedriver,我在自动化测试方面完全是个呆子,我正试图通过Youtube学习如何做到这一点 在这个来自Edureka的课程中,有一个例子,他们试图处理一个异常,在他们运行脚本后,系统在控制台中向他们显示一条我无法获取的消息 package co.edureka.selenium.demo; import java.util.NoSuchElementException; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver
package co.edureka.selenium.demo;
import java.util.NoSuchElementException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class HandlingExceptions {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
Thread.sleep(3000);
try {
driver.findElement(By.name("fake")).click();
}catch (NoSuchElementException e) {
System.out.println("element is not found");
System.out.println("Hello");
//throw(e);
}
System.out.println("Hello");
}
}
这是他们正在运行的Java脚本,最后在控制台中,他们得到了这个结果
但是我得到了完全不同的东西,即使我的代码完全相同
我做错了什么?您正在使用“import java.util.NoSuchElementException;
“位于文件顶部,请删除并使用下面的文件
org.openqa.selenium.NoSuchElementExceptionAddSystem.out.println(e)代码>在异常块中