开发者

Eclipse / Selenium unable to locate correct library for verifyText, isElementPresent etc

I am new to Eclipse and trying to run a simple selenium test.

However, I get the error message when I mouse over certain elements such as assertTrue with:

开发者_Go百科

"void junit.framework.Assert.assterTrue(boolean condition) Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source."

I have added all the following referenced libraries (including the path details of their location on my 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

Plus some junit files (4.7).

I have managed to fix similar problems with verifyText by opening the declaration and then trying to associate each selenium jar in turn until Eclipse recognises it. However, none of them seem to work with assertTrue. Does anyone have any idea which other Selenium downloads I should use if I need to do something else? ================================================================================== Edit: I found the answer. I needed to link AssertTrue with one of the junit files instead! ==================================================================================

Paste of code below:

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();
}
}


The error "This element has no attached Javadoc and the Javadoc could not be found in the attached source" indicates that the classpath for JDK is not set.

To find the exact path where java is installed give the below command:

    which java

OUTPUT: /usr/bin/java Then set the path for JDK using the below commands:

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

To check whether the java path is set correctly give the below command:

   java -version
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜