这是我的代码:
import java.io.IOException;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import net.jsourcerer.webdriver.jserrorcollector.JavaScriptError; //jar file used
public class js
{
private static WebDriver driver;
@BeforeClass public static void setUp() throws IOException
{
FirefoxProfile ffProfile = new FirefoxProfile();
JavaScriptError.addExtension(ffProfile);
driver = new FirefoxDriver(ffProfile);
driver.get("WEBSITE NAME"); /*have to check all pages of a website*/
}
@AfterClass public static void tearDown()
{
List<JavaScriptError> jsErrors = JavaScriptError.readErrors(driver);
System.out.println("###start displaying errors");
for(int i = 0; i < jsErrors.size(); i++)
{
System.out.println(jsErrors.get(i).getErrorMessage());
System.out.println(jsErrors.get(i).getLineNumber());
System.out.println(jsErrors.get(i).getSourceName());
}
System.out.println("###start displaying errors");
driver.close(); driver.quit();
}
@Test
public void returnJavascriptErrors() throws InterruptedException {
Thread.sleep(5000);
}
}
它正在运行,但如何在网站上检查所有页面。它显示0错误,我想知道它是否只检查主页