引起的原因:java.lang.ClassNotFoundException:com.google.common.base.function将在selenium中处理?

时间:2017-03-27 16:26:13

标签: selenium selenium-webdriver selenium-grid

引起: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");        
    }
}

4 个答案:

答案 0 :(得分:2)

我认为您在构建路径中缺少Selenium独立服务器。添加所需的版本,你会很高兴...

selenium-server-standalone-version.jar

答案 1 :(得分:1)

在项目中添加 selenium-server-standalone-version.jar 文件。问题将得到解决

答案 2 :(得分:0)

以下是您遇到的问题的解决方案:

您已将注释用作@Before。通过TestNG的文档,您只能使用以@Before开头的以下注释:

  1. @BeforeSuite
  2. @BeforeClass
  3. @BeforeTest
  4. @BeforeGroups
  5. @BeforeMethod
  6. 使用适合您的测试策略的那个。这将解决您的问题。请记住仅从TestNG导入类。

    如果这有助于您,请告诉我。

答案 3 :(得分:0)

使用@BeforeTest代替@Before,因为此setup()将在测试开始时运行。