我在 Intellij 中使用 Java/Selenium/JUnit/ANT,当我运行我的 build.xml 文件并且它到达我的测试运行器时,我开始收到不可变映射错误。我没有任何不可变对象。
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.IOException;
public class Auth {
public WebDriver driver;
public WebDriverWait wait;
public static void main(String[] args){
System.out.println("Let's Go.");
}
public boolean doSetup() throws IOException {
System.setProperty("webdriver.edge.driver", "C:/Path/to/MicrosoftWebDriver.exe" );
driver = new EdgeDriver();
Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
String browserName = cap.getBrowserName().toLowerCase();
//System.out.println(browserName);
if(browserName.equals("microsoftedge")) {
}
return true;
}
然后在我的测试中将其作为 @Before 调用,并在 @After 中再次调用驱动程序
@Before
public void signIn() throws Exception{
auth.doSetup();
}
@After
public void tearDown() throws Exception {
auth.driver.quit();
}
这引发了以下错误:
<testcase classname="adminTests.adminWorkspaceMenu" name="adminWorkspace" time="0.025">
<error message="com/google/common/collect/ImmutableMap" type="java.lang.NoClassDefFoundError">java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:249)
at org.openqa.selenium.edge.EdgeDriverService$Builder.<init>(EdgeDriverService.java:72)
at org.openqa.selenium.edge.EdgeDriverService.createDefaultService(EdgeDriverService.java:68)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:96)
at userTests.Auth.doSetup(Auth.java:33)
我想要一个解决方法来避免这个错误,我最初在 Eclipse 中编写这个项目时没有遇到这个问题,但是由于各种原因,我不得不切换到 Intellij,现在我遇到了这个问题。
萧十郎
相关分类