gpt4 book ai didi

java - 错误 : Element q not found. ..Eclipse 中的 SeleniumRC...提供了堆栈跟踪和代码..请解决?

转载 作者:行者123 更新时间:2023-12-01 15:22:52 25 4
gpt4 key购买 nike

下面的代码是用 Java 为 Selenium 编写的代码,并尝试在 Selenium Standalone 服务器中执行/运行。但是,出现错误,并附加了堆栈跟踪。

package package1_IdentifyPageOpened;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.thoughtworks.selenium.*;

public class Class1 {

Selenium selenium=null;
@Before
public void setUp() throws Exception {


selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.portware.com");
selenium.setSpeed("1000");
selenium.start();
//selenium.open();
}
@Test
public void testExported() throws Exception {
selenium.open("/selenium/search.php");
selenium.type("q", "Selenium-RC");
selenium.click("btnG");
}
@After
public void tearDown() throws Exception {
selenium.stop();
}




/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

}

}

堆栈跟踪:

com.thoughtworks.selenium.SeleniumException: ERROR: Element q not found
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
at com.thoughtworks.selenium.DefaultSelenium.type(DefaultSelenium.java:317)
at package1_IdentifyPageOpened.Class1.testExported(Class1.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

尝试打开浏览器“firefox”(代码中给出的浏览器),然后执行测试用例,并给出测试用例的执行时间(即setSpeed-1000),因为这些是一些分辨率,这是在之前的实例中提供的。但是,还是没能解决。请帮助..!

最佳答案

此 URL 无效 - http://www.portware.com/selenium/search.php 。 Selenium 打开此 URL 并检查名为“q”的元素。由于该页面不存在,因此无法找到该元素。

关于java - 错误 : Element q not found. ..Eclipse 中的 SeleniumRC...提供了堆栈跟踪和代码..请解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10621449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com