简体   繁体   English

如何在Eclipse中以TestNG的形式执行Selenium Webdriver测试

[英]How to execute Selenium Webdriver test as TestNG in eclipse

I'm using Selenium WebDriver with Java and TestNG as Test framework. 我正在将Selenium WebDriver与Java和TestNG用作测试框架。 I'm using Eclipse (eclipse-jee-indigo-SR2-win32) as IDE. 我正在使用Eclipse(eclipse-jee-indigo-SR2-win32)作为IDE。 I want to execute my test (java file) in eclipse as TestNG test. 我想在Eclipse中执行我的测试(java文件)作为TestNG测试。

For example, I have Registration.java and I want to run within eclipse as TestNG test. 例如,我有Registration.java,我想在Eclipse中运行TestNG测试。 For running this file I did the following steps: 为了运行此文件,我执行了以下步骤:

  1. Right click on Registration.java 右键单击Registration.java
  2. Mouse over "Run As" at pop up 将鼠标悬停在“运行方式”上方

But I didn't find any option of TestNG to run my test. 但是我找不到TestNG的任何选项来运行测试。 What should be done in eclipse for this? 在月食中应该做什么呢?

It needs to install TestNG plug-in for Eclipse. 它需要安装Eclipse的TestNG插件。 To do this follow the steps below: 为此,请按照以下步骤操作:

  1. Open eclipse 日食
  2. Go to Help --> Eclipse Marketplace 转到帮助-> Eclipse Marketplace
  3. Search as TestNG 搜索为TestNG
  4. Click Install for "TestNG for Eclipse" section 单击“ TestNG for Eclipse”部分的安装
  5. Follow the step by step instruction 遵循分步说明
  6. After successful installation observe TestNG on Window --> Preferences (TestNG is enlisted at left panel) 成功安装后,在窗口->首选项上观察TestNG(TestNG在左侧面板中列出)

[Note: Right click on Registration.java -> Mouse over Run As -> Click TestNG Test. [注意:右键单击Registration.java->将鼠标悬停在Run As->单击TestNG Test。 Your test Registration would be executed] 您的测试注册将被执行]

Is it just this file that you can't run as a TestNG test or anything, ie have you configured Eclipse for TestNG at all yet? 仅仅是不能作为TestNG测试运行的文件还是什么,即您是否已经为TestNG配置了Eclipse? If not the first place to look is here http://testng.org/doc/eclipse.html 如果不是第一眼的地方,请访问http://testng.org/doc/eclipse.html

Please follow Koly answers. 请遵循Koly的答案。 That is correct one! 那是正确的!

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

相关问题 Selenium WebDriver:如何在失败的测试用例中在testNG中执行完整的测试 - Selenium WebDriver: How to execute complete Test in testNG for a failed test case 如何使用共享的webdriver执行testng测试用例? - How to execute testng test cases with shared webdriver? 如何在TestNg和Eclipse中执行测试服 - How to execute Test suit in TestNg and eclipse 如何远程执行测试代码(maven/java/testNG/selenium)? - How to execute test code (maven/java/testNG/selenium) remotely? 如何使用Selenium Webdriver在Testlink中执行测试用例 - How to use Selenium webdriver to execute test cases in Testlink 如何将我的Eclipse Maven Selenium Webdriver TestNG Java项目从一台PC转移到另一台PC? - How to transfer my Eclipse Maven Selenium Webdriver TestNG Java project from one PC to another? 将Selenium WebDriver与TestNG和DataProviders一起使用-如何断言? - Using Selenium WebDriver with TestNG and DataProviders - how to assert? 如何在 selenium webdriver testng 中实现接口概念 - How to implement interface concept in selenium webdriver testng Selenium WebDriver所有并行测试都在一个窗口中执行-TestNG-Java - Selenium WebDriver All Parallel Tests Execute In A Single Window - TestNG - Java 如何在没有testng / maven的情况下从命令行运行Selenium Webdriver测试用例 - How to run selenium webdriver test cases from command line without testng/maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM