Selenium的第一个脚本问题



有人能解释一下的问题是什么吗

[RemoteTestNG]检测到TestNG版本7.4.0SLF4J:加载类"失败;org.slf4j.impl.StaticLoggerBinder"。SLF4J:默认为无操作(NOP)记录器实现SLF4J:请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder了解更多详细信息。在端口44625上启动ChromeDriver 93.0.4577.63(ff5c0da2ec0adead5550e6c7e98417dac77d98a refs/branch-heads/4577@{#1135})只允许本地连接。请参阅https://chromedriver.chromium.org/security-considerations以获取有关保持ChromeDriver安全的建议。ChromeDriver已成功启动。2021年10月3日下午7:39:31 org.openqa.selenium.remote.ProtocolHandshake createSession信息:检测到的方言:W3C失败:测试1org.openqa.selenium.NoSuchElementException:没有这样的元素:无法定位元素:{"方法"会话信息:chrome=93.0.4577.82)有关此错误的文档,请访问:https://www.seleniumhq.org/exceptions/no_such_element.html内部版本信息:版本:3.141.59,修订:e82be7d358,时间:2018-11-14T08:17:03系统信息:host:"DESKTOP-T9AC67A",ip:"192.168.8.103",os.name:"Windows 10",os.arch:"amd64",os.version:"10.0",java.version:"17"驾驶员信息:org.openqa.selenium.chrome.ChromeDriver功能{acceptInsecureCerts:false,browserName:chrome,browserVersion:93.0.4577.82,chrome:{chromedriverVersion:93..4577.63(ff5c0da2ec0ad…,userDataDir:C:\Users\HP\AppData\Local\T…},goog:chromeOptions:{debuggerAddress:localhost:58962},javascriptEnabled:true,networkConnectionEnabled:false,pageLoadStrategy:normal,platform:WINDOWS,platformName:WINDOWS,proxy:proxy(),setWindowRect:true,strictFileInteractability:false,超时:{隐式:0,页面加载:300000,脚本:30000},unhandledPromptBehavior:解除并通知,webauthn:扩展:credBlob:true,webauthn:扩展:largeBlob:true,webauthn:virtualAuthenticators:true}会话ID:6a5cd2f8473cf85881207039d4329872***元素信息:{Using=name,value=uid}位于java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)位于java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessor Impl.java:77)位于java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessor Impl.java:45)位于java.base/java.lang.reflect.CConstructor.newInstanceWithCaller(Constructor.java:499)位于java.base/java.lang.reflect.CConstructor.newInstance(Constructor.java:480)网址:org.openqa.selene.remote.http.W3CttpResponseCodec.createException(W3CHttpResponceCodec.java:187)网址:org.openqa.selene.remote.http.W3CttpResponseCodec.decode(W3CHttpResponceCodec.java:122)网址:org.openqa.selene.remote.http.W3CttpResponseCodec.decode(W3CHttpResponceCodec.java:49)网址:org.openqa.selene.remote.HttpCommandExecution.execute(HttpCommandExecutior.java:158)网址:org.openqa.selene.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)网址:org.openqa.selene.remote.RemoteWebDriver.exexecute(RemoteWebDriver.java:552)网址:org.openqa.selene.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)网址:org.openqa.selene.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:404)网址:org.openqa.selene.By$ByName.findElement(By.java:284)网址:org.openqa.selene.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)位于seleniumPackage.SeleniumTestClass.test1(SeleniumTestClass.java:31)位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)位于java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)位于java.base/java.lang.reflect.Method.ioke(Method.java:568)位于org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelpr.java:133)位于org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)位于org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)网址:org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)网址:org.testng.internal.TestInvoker$MethodInvocationAgent.ioke(TestInvoker.java:824)位于org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)位于org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)网址:org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)位于java.base/java.util.ArrayList.forEach(ArrayList.java:1511)网址:org.testng.TestRunner.privateRun(TestRunner.java:794)网址:org.testng.TestRunner.run(TestRunner.java:596)网址:org.testng.SuiteRunner.runTest(SuiteRunner.java:377)网址:org.testng.SuiteRunner.runSequencely(SuiteRunner.java:371)网址:org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)网址:org.testng.SuiteRunner.run(SuiteRunner.java:276)网址:org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)位于org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)位于org.testng.testng.runSuitesSequencely(testng.java:1212)位于org.testng.testng.runSuitesLocally(testng.java:1134)网址:org.testng.testng.runSuites(testng.java:1063)网址:org.testng.testng.run(testng.java:1031)网址:org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)位于org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)网址:org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

NoSuchElementException:{"方法&quot请打开开发人员工具并验证您的xpath是否正确?

如果它是正确的,你正在做一些操作加载网站。请添加等待时间。

WebDriverWait wait = new WebDriverWait(driver, 20);
By divCss = By.xpath(("//*[@id='resultTable']//tbody/tr//a"));
wait.until(ExpectedConditions.elementToBeClickable(divCss));
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(divCss));

最新更新