如何引起:java.lang.ClassNotFoundException:com.google.common.base.function 将在 selenium 中处理?
How Caused by: java.lang.ClassNotFoundException:com.google.common.base.function will be handled in selenium?
原因:java.lang.ClassNotFoundException:com.google.common.base.function 将在 selenium 中处理
通过 Webdriver 运行 时出现此错误。
public class Logintoaccount {
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.ie.driver", "d:\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
}
@Test
public void test() {
//System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
}
}
这是您遇到的问题的解决方案:
您已经将注解用作@Before。按照 TestNG 的文档,您只能使用以下以 @Before 开头的注释:
- @BeforeSuite
- @BeforeClass
- @BeforeTest
- @BeforeGroups
- @BeforeMethod
使用适合您的测试策略的那个。这将解决您的问题。请记住仅从 TestNG 导入 类 。
如果这对你有帮助,请告诉我。
使用@BeforeTest 而不是@Before,因为此setup() 将在测试开始时运行。
我认为您在构建路径中缺少 Selenium 独立服务器。添加所需的版本,您就可以开始了...
selenium-server-standalone-version.jar
在项目中添加selenium-server-standalone-version.jar文件。问题将得到解决
原因:java.lang.ClassNotFoundException:com.google.common.base.function 将在 selenium 中处理
通过 Webdriver 运行 时出现此错误。
public class Logintoaccount {
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.ie.driver", "d:\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
}
@Test
public void test() {
//System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
}
}
这是您遇到的问题的解决方案:
您已经将注解用作@Before。按照 TestNG 的文档,您只能使用以下以 @Before 开头的注释:
- @BeforeSuite
- @BeforeClass
- @BeforeTest
- @BeforeGroups
- @BeforeMethod
使用适合您的测试策略的那个。这将解决您的问题。请记住仅从 TestNG 导入 类 。
如果这对你有帮助,请告诉我。
使用@BeforeTest 而不是@Before,因为此setup() 将在测试开始时运行。
我认为您在构建路径中缺少 Selenium 独立服务器。添加所需的版本,您就可以开始了...
selenium-server-standalone-version.jar
在项目中添加selenium-server-standalone-version.jar文件。问题将得到解决