简体   繁体   English

无法在Eclipse中成功运行硒测试

[英]Can't successfully run a selenium test in Eclipse

I can't run my first Selenium test in Eclipse. 我无法在Eclipse中运行我的第一个Selenium测试。

I'm pretty sure that all the configurations are OK. 我很确定所有配置都可以。

You can see my class + the exception in the screenshot below: 您可以在下面的屏幕截图中看到我的课程+异常:

http://s12.postimg.org/ik0wqb2f1/2015_02_08_1725.png http://s12.postimg.org/ik0wqb2f1/2015_02_08_1725.png

Please your assistance. 请您的协助。

Thanks a lot, 非常感谢,

Idan. IDAN。

You should use Test NG plugin for Eclipse, you can download from here: 您应该为Eclipse使用Test NG插件,可以从此处下载:

Test NG plugin for Eclipse 测试Eclipse的NG插件

And don't forget to add the Maven dependency to your project too: 并且不要忘记也将Maven依赖项添加到您的项目中:

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.8</version>
    <scope>test</scope>
</dependency>

Probably you also need some of the following libraries. 可能您还需要以下一些库。 If they are needed could be added by Maven dependency: 如果需要它们,可以通过Maven依赖项添加:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.50.1</version>
    <scope>test</scope>
</dependency>

Finally, when creating your test, set the gecko driver property and @Test annotation from org.testng.annotations.Test 最后,在创建测试时,从org.testng.annotations.Test设置gecko驱动程序属性和@Test批注

@BeforeTest
public void beforeTest() {
     System.setProperty("webdriver.gecko.driver", geckoDriverLocation);
}

@Test
public void myTest() {

    driver.get("https://myRUL/home");
    [...]
}

There is nothing wrong in your code. 您的代码没有错。 There is some problem with your package. 您的包裹有问题。 Try creating new project and import jars correctly by following steps in the link below. 请按照以下链接中的步骤尝试创建新项目并正确导入jar。

http://www.guru99.com/installing-selenium-webdriver.html http://www.guru99.com/installing-selenium-webdriver.html

It looks to me like you haven't set up your project correctly. 在我看来,您没有正确设置项目。 Right click on your project, then go to: 右键单击您的项目,然后转到:

--> Build path...-->Configure build path... ->构建路径...-->配置构建路径...

Once there, go to the Libraries tab, and remove that giant list of .jar files. 到达那里后,转到“库”选项卡,然后删除该.jar文件的庞大列表。

Since System and String are not resolving, it looks like you are missing the JRE System Library, so press [Add Library...] and add it. 由于SystemString无法解析,因此您似乎缺少了JRE系统库,因此请按[Add Library ...]并将其添加。

Then, for you Selenium setup, just press [Add External JARs...] and add only: 然后,对于您的Selenium设置,只需按[Add External JARs ...]并仅添加:

  • selenium-java-2.44.0.jar 硒-Java的2.44.0.jar
  • selenium-server-standalone-2.44.0.jar 硒的服务器独立,2.44.0.jar

And see if you are able to run it after that. 看看之后是否能够运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM