[英]java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
I am trying to run a Java project using page factory and page object model, I want to run it on Chrome, IE and on Firefox, but I am not able to run it on Firefox, the browser is not opening, I am getting this error : java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
我正在尝试使用页面工厂和页面对象模型运行Java项目,我想在Chrome,IE和Firefox上运行它,但是我无法在Firefox上运行它,浏览器没有打开,我得到了这个错误:
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
My Code is : 我的代码是:
@BeforeMethod
public static void openBrowser() {
String browser = "";
if (browser.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", "src\\test\\Resources\\BrowserDrivers\\chromedriver.exe");
driver = new ChromeDriver();
}
else if (browser.equalsIgnoreCase("ie")){
System.setProperty("webdriver.ie.driver", "src\\test\\Resources\\BrowserDrivers\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
else {
driver = new FirefoxDriver();
}
driver = new FirefoxDriver();
driver.get("http://www.google.com/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
@AfterMethod
public static void closeBrowser(){
driver.quit();
}
See eg this Github issue , some dependencies can drag in an outdated version of xml-apis which can cause this, a solution that worked for me was to add a specific dependency on xml-apis, eg with Maven something like 参见例如这个Github问题 ,一些依赖项可能会拖入过时的xml-apis版本,这可能会导致这种情况,对我有用的解决方案是在xml-apis上添加特定的依赖项,例如使用Maven之类的东西
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.