【问题标题】:Eclipse / Selenium unable to locate correct library for verifyText, isElementPresent etcEclipse / Selenium 无法为 verifyText、isElementPresent 等找到正确的库
【发布时间】: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();
}
}

【问题讨论】:

    标签: java eclipse selenium


    【解决方案1】:

    错误“此元素没有附加的 Javadoc,在附加的源中找不到 Javadoc”表示未设置 JDK 的类路径。

    要找到安装 java 的确切路径,请输入以下命令:

        which java
    

    输出:/usr/bin/java 然后使用以下命令设置 JDK 的路径:

       export PATH=$PATH:/usr/bin/java
       export JAVA_HOME=/usr/bin/java
    

    要检查java路径是否设置正确,请给出以下命令:

       java -version
    

    【讨论】:

    • 您好 Aruna,在 cmd shell 中,它不理解“which”或“export”这两个词。 italic_("'*' 不是内部或外部命令、可运行程序或批处理文件")_italic。 Java -version 工作正常 italic_(java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02,混合模式,共享) _斜体)。您还有其他建议吗?
    猜你喜欢
    • 1970-01-01
    • 2021-11-12
    • 2015-01-17
    • 2013-11-22
    • 1970-01-01
    • 2018-03-09
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多