我正在将Chrome浏览器版本79.0.3945.79与Chrome驱动程序:ChromeDriver 79.0.3945.36
下面是我正在使用的代码。
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Driver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("window-size=1200x600");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize(); // maximize window
driver.manage().deleteAllCookies(); // delete all the cookies
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.google.com");
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("Java");
---错误消息-跟踪如下---
org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“ method”:“ xpath”,“ selector”:“ // input [@ name ='q']”} (会议信息:headless chrome = 79.0.3945.79) (驱动程序信息:chromedriver = 79.0.3945.36(3582db32b33893869b8c1339e8f4d9ed1816f143-refs / branch-heads / 3945 @ {#614})),platform = Windows NT 6.1.7601 SP1 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:10.06秒 有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html 内部版本信息:版本:'2.53.0',修订版本:'35ae25b1534ae328c771e0856c93e187490ca824',时间:'2016-03-15 10:43:46' 系统信息:主机:'W01B77WL',ip:'10 .129.5.50',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_144 ' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能[{mobileEmulationEnabled = false,超时= {implicit = 0,pageLoad = 300000,脚本= 30000},hasTouchScreen = false,platform = XP,acceptSslCerts = false,goog:chromeOptions = {debuggerAddress = localhost:49314},acceptInsecureCerts = false ,webStorageEnabled = true,browserName = chrome,takesScreenshot = true,javascriptEnabled = true,setWindowRect = true,unexpertAlertBehaviour = ignore,applicationCacheEnabled = false,rotatable = false,networkConnectionEnabled = false,chrome = {chromedriverVersion = 79.0.3945.36(3582db32b33893869b8c1339s8f4d9ed18 branch-heads / 3945 @ {#614}),userDataDir = C:\ Users \ t523760 \ AppData \ Local \ Temp \ scoped_dir15468_643969098},takeHeapSnapshot = true,pageLoadStrategy = normal,strictFileInteractability = false,databaseEnabled = false,handlesAlerts = true,版本= 79.0.3945.79,browserConnectionEnabled = false,proxy = {},nativeEvents = true,locationContextEnabled = true,cssSelectorsEnabled = true}]] 会话ID:9a85826c6fce9b59cbc489ecde141746 ***元素信息:{使用= xpath,值= //输入[@ name ='q']} 在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处 在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363) 在org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500) 在org.openqa.selenium.By $ ByXPath.findElement(By.java:361) 在org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355) 在com.ubs.aem.test.UnitTest.testExecution(UnitTest.java:47) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498) 在org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:50) 在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 在org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 在org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290) 在org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71) 在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 在org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58) 在org.junit.runners.ParentRunner上$ 2.evaluate(ParentRunner.java:268) 在org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 在org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) 在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) 在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) 在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)