【发布时间】:2011-06-24 11:49:53
【问题描述】:
我是 Eclipse 新手,正在尝试运行一个简单的 selenium 测试。
但是,当我将鼠标悬停在某些元素(例如 assertTrue 上)时,我会收到错误消息:
"void junit.framework.Assert.assterTrue(布尔条件) 注意:此元素没有附加的 Javadoc,并且在附加的源中找不到 Javadoc。"
我添加了以下所有引用的库(包括它们在我的 PC 上的位置的路径详细信息): selenium-java-2.0rc3.jar selenium-java-2.0rc3-srs.jar selenium-server-standalone-2.0rc3.jar selenium-java-2.0b3.jar selenium-java-2.0b3-srs.jar
加上一些junit文件(4.7)。
通过打开声明然后尝试依次关联每个 selenium jar 直到 Eclipse 识别它,我设法解决了 verifyText 的类似问题。但是,它们似乎都不适用于 assertTrue。如果我需要做其他事情,有谁知道我应该使用哪些其他 Selenium 下载? ==================================================== ================================= 编辑:我找到了答案。我需要将 AssertTrue 与其中一个 junit 文件链接起来! ==================================================== =================================
以下代码粘贴:
package com.eviltester.selenium2;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
public class MySecondSeleniumTest extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.uk/");
selenium.start();
}
@SuppressWarnings({ "deprecation", "deprecation" })
@Test
public void testSel1() throws Exception {
Selenium selenium2 = selenium;
selenium2.open("/search?source=ig&hl=en&rlz=&q=thetechnicalauthor+blog&aq=f&aqi=&aql=&oq=");
selenium2.click("link=The Technical Author: How to put keywords into your blog");
selenium2.waitForPageToLoad("30000");
*assertTrue*(selenium2.isElementPresent("//div[@class='mm']"));
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
【问题讨论】: