我得到
尝试在Chrome上运行测试时出现'无效的选择器:无法在'XMLHttpRequest'上执行'send': 无法加载“ {website}”
错误。我正在运行Chrome version 76.0.3809.132
,并在使用Chromedriver version 76.0.3809.126.
,这个问题刚刚在上周开始出现。
在调试测试时,将加载网站并开始运行抽象测试库。一旦尝试调用@beforeTest方法,它将失败。
这是错误的堆栈跟踪:
java.lang.RuntimeException:无法针对以下情况运行BeforeTestCase:testcases.analysis.stressscenarios.byriskfactor.TestColumnsDisplayed [14:50:29] [步骤1/2]在testlisteners.TestListenerFactory.lambda $ runListenersFor $ 10(TestListenerFactory.java:25)〜[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testlisteners.TestListenerFactory $$ Lambda $ 7 / 460702435.accept(未知来源)〜[?:?] [14:50:29] [Step 1/2] at java.lang.Iterable.forEach(Unknown Source)〜[?:1.8.0_45] [14:50:29] [步骤1/2]在testlisteners.TestListenerFactory.runListenersFor(TestListenerFactory.java:18)〜[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testcases.TestCaseScript $ Test.lambda $ test $ 5(TestCaseScript.java:65)〜[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testcases.TestCaseScript $ Test $$ Lambda $ 257 / 1435820321.run(Unknown Source)〜[?:?] [14:50:29] [步骤1/2]在testcases.TestCaseScript $ Test.executor(TestCaseScript.java:93)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testcases.TestCaseScript $ Test.test(TestCaseScript.java:65)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[?:1.8.0_45] [14:50:29] [步骤1/2]位于sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[?:1.8.0_45] [14:50:29] [步骤1/2]位于sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[?:1.8.0_45] [14:50:29] [Step 1/2] at java.lang.reflect.Method.invoke(Unknown Source)〜[?:1.8.0_45] [14:50:29] [步骤1/2] org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:50)[fubar.jar:SNAPSHOT] [14:50:29] [Step 1/2] org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2] org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2] org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2] org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)[fubar.jar:SNAPSHOT] [14:50:29] [Step 1/2] org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58)[fubar.jar:SNAPSHOT] [14:50:29] [Step 1/2] org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.ParentRunner.run(ParentRunner.java:363)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testsuites.ParameterizedJUnit4RunnerBuilder $ ParameterizedJUnit4Runner.run(ParameterizedJUnit4RunnerBuilder.java:88)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]位于org.junit.runners.Suite.runChild(Suite.java:128)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testsuites.ParallelTestSuite.access $ 200(ParallelTestSuite.java:31)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testsuites.ParallelTestSuite $ 1.lambda $ evaluate $ 13(ParallelTestSuite.java:144)[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2]在testsuites.ParallelTestSuite $ 1 $$ Lambda $ 252 / 319426406.run(未知来源)[fubar.jar:SNAPSHOT] [14:50:29] [Step 1/2] at java.util.concurrent.Executors $ RunnableAdapter.call(Unknown Source)> [?:1.8.0_45] [14:50:29] [Step 1/2] at java.util.concurrent.FutureTask.run(Unknown Source)[?:1.8.0_45] [14:50:29] [Step 1/2] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[?:1.8.0_45] [14:50:29] [步骤1/2],位于java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)[?: 1.8.0_45] [14:50:29] [Step 1/2] at java.lang.Thread.run(Unknown Source)[?:1.8.0_45] [14:50:29] [步骤1/2]造成原因:java.lang.reflect.InvocationTargetException [14:50:29] [步骤1/2]在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[?:1.8.0_45] [14:50:29] [步骤1/2]位于sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[?:1.8.0_45] [14:50:29] [步骤1/2]位于sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[?:1.8.0_45] [14:50:29] [Step 1/2] at java.lang.reflect.Method.invoke(Unknown Source)〜[?:1.8.0_45] [14:50:29] [步骤1/2]在testlisteners.TestListenerFactory.lambda $ runListenersFor $ 10(TestListenerFactory.java:24)〜[fubar.jar:SNAPSHOT] [14:50:29] [步骤1/2] ...还有34 [14:50:29] [步骤1/2]原因:org.openqa.selenium.InvalidSelectorException:无效的选择器:无法在“ XMLHttpRequest”上执行“发送”:无法加载“ {website}”。
尝试降级Chromedriver,但没有结果。尝试重新启动计算机,但未成功。验证这不是由过多的孤立驱动程序实例引起的。
这是失败时正在运行的代码:
public static void runListenersFor(Class<? extends Annotation> annotationType, Class<?> testClass){
Set<Method> listeners = TestListenerFactory.findListenersOfType(annotationType);
listeners.forEach( (Method m) -> {
ArrayList<String> listeningTo = Arrays.stream(getClassesToListenTo(m.getAnnotation(annotationType))).collect(
ArrayList::new, (resp, elem) -> resp.add(elem.getName()), ArrayList::addAll
);
if (listeningTo.size() == 0 || listeningTo.contains(testClass.getName())) {
logger.info("Invoking @"+annotationType.getSimpleName()+":" + m.getName());
try { m.invoke(m.getDeclaringClass().newInstance()); }
catch (Throwable t) { throw new RuntimeException("Unable to to run "+annotationType.getSimpleName()+" for: " + testClass.getName(), t); }
}
});
}
它在try { m.invoke(m.getDeclaringClass().newInstance()); }
上失败