【问题标题】:How can I run the selenium test case?如何运行 selenium 测试用例?
【发布时间】:2012-08-06 06:19:59
【问题描述】:

我在我的应用程序中编写了一个 selenium 示例测试用例。然后我右键单击该文件并选择“测试文件”。结果

Testsuite: com.MyApp.SampleSeleniumTest
Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.265 sec

Testcase: warning(junit.framework.TestSuite$1): FAILED
No tests found in com.MyApp.SampleSeleniumTest
junit.framework.AssertionFailedError: No tests found in com.MyApp.SampleSeleniumTest
Test com.MyApp.SampleSeleniumTest FAILED

我的代码是

package com.MyApp;

import com.thoughtworks.selenium.*;
import org.junit.Test;

public class SampleSeleniumTest extends SeleneseTestCase {

   @Override
   public void setUp() throws Exception {
      setUp("http://www.google.com", "*firefox");
   }

   @Test
   public void whatever() throws Exception {
       selenium.open("/");
       assertTrue(selenium.isTextPresent("Explore"));
   }
}

【问题讨论】:

  • 您确定您使用的是 JUnit 4.x 吗?否则不能使用注解。
  • 是的,我使用的是 JUnit 4.8.2。它现在工作。无论如何感谢您的回复

标签: selenium selenium-rc selenium-webdriver selenium-ide selenium-grid


【解决方案1】:

这是另一种方法

package com.MyApp;

import com.thoughtworks.selenium.*;
import org.junit.*;

public class SampleSeleniumTest extends SeleneseTestCase {

    @Before
    public void setUp() throws Exception {
        selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://urlofyourApp");
        selenium.start();
    }

    @Test
    public void testTestRC() throws Exception {
        selenium.open("/");
    assertTrue(selenium.isTextPresent("Explore"));

    }

    @After
    public void tearDown() throws Exception {
        selenium.stop();
    }
}

【讨论】:

  • 普拉尚特,感谢您的回复。但我仍然遇到同样的错误
  • @Gnik:您使用的是 netbeans,对吗?尝试命名测试方法,使其以'testWhatever()'之类的测试开始
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-23
  • 1970-01-01
  • 2015-05-10
  • 2010-10-03
  • 1970-01-01
相关资源
最近更新 更多