简体   繁体   English

线程“主” org.openqa.selenium.WebDriverException中的异常:未知错误:无法聚焦元素

[英]Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot focus element

I have been trying to use Selenium sendkeys() without success using Chrome. 我一直在尝试使用Selenium sendkeys()而不成功使用Chrome。 I've researched similar questions here that seemed related without success. 我在这里研究了类似的问题,这些问题似乎没有成功。 I can spawn the URL, invoke buttons (click()) but when I attempt to enter a value within a specific text field I get: 我可以生成URL,调用按钮(click()),但是当我尝试在特定文本字段中输入值时,我得到:

"Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot focus element." ““线程“主”中的异常org.openqa.selenium.WebDriverException:未知错误:无法聚焦元素。”

Would appreciate any help. 将不胜感激。 Thank you! 谢谢!

Here's a snippet of code: 这是一段代码:

WebElement titleBox = driver.findElement(By.xpath("//*[@id='root']/div/div[2]/div/div/div[2]/div[1]"));
titleBox.click();
titleBox.sendKeys("Test Survey Title");

Here's the stack trace: 这是堆栈跟踪:

Starting ChromeDriver 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b) on port 43615 Only local connections are allowed. 在端口43615上启动ChromeDriver 2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b)仅允许本地连接。 May 26, 2017 3:42:50 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot focus element (Session info: chrome=58.0.3029.110) (Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.5 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 43 milliseconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'Enriques-MacBook-Pro.local', ip: '10.0.0.208', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b), userDataDir=/var/folders/55/jxcw642x45 2017年5月26日3:42:50 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO:检测到方言:线程“ main”中的OSS异常org.openqa.selenium.WebDriverException:未知错误:无法聚焦元素(会话信息: chrome = 58.0.3029.110)(驱动程序信息:chromedriver = 2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform = Mac OS X 10.12.5 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:43毫秒构建信息:版本:'3.4.0',版本:'未知',时间:'未知'系统信息:主机:'Enriques-MacBook-Pro.local',ip:'10 .0.0.208',操作系统名称:'Mac OS X',os.arch:'x86_64',os.version:'10 .12.5'​​,java.version:'1.8.0_131'驱动程序信息:org.openqa.selenium.chrome.ChromeDriver功能[{applicationCacheEnabled = false,可旋转= false,mobileEmulationEnabled = false,networkConnectionEnabled = false,chrome = {chromedriverVersion = 2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),userDataDir = / var / folders / 55 / jxcw642x45 93njd3nnysck_80000gn/T/.org.chromium.Chromium.4miVBB}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=58.0.3029.110, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}] Session ID: c0d55118bf095a12cb6e105b581b149e at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java 93njd3nnysck_80000gn / T / .org.chromium.Chromium.4miVBB},需要HeapSnapshot = true,pageLoadStrategy = normal,databaseEnabled = false,handlesAlerts = true,hasTouchScreen = false,版本= 58.0.3029.110,平台= MAC,browserConnectionEnabled = false,nativeEvents = true,acceptSslCerts = true,locationContextEnabled = true,webStorageEnabled = true,browserName = chrome,takesScreenshot = true,javascriptEnabled = true,cssSelectorsEnabled = true,unexpectedAlertBehaviour =}]会话ID:c0d55118bf095a12cb6e105b581b149e位于sun.reflect.NativeConstructInstanceInstance0()上。在组织处的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.throwIfResponseFailed(ErrorHandler.java)上的openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215) :167) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272) at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96) at LaunchChrome.main(LaunchChrome.java:36) :167),位于org.openqa.selenium.remote的org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272),位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)。 LaunchChrome.main(LaunchChrome.java:36)上的RemoteWebElement.sendKeys(RemoteWebElement.java:96)

You can try following code using actions class to have focus on your element before you can interact with it: 您可以尝试使用actions类遵循以下代码,以便在与元素进行交互之前将重点放在元素上:

WebElement titleBox = driver.findElement(By.xpath("//*@id='root']/div/div[2]/div/div/div[2]/div[1]"));

Actions action = new Actions(driver);
action.moveToElement(titleBox).build().perform();
titleBox.click();
titleBox.sendKeys("Test Survey Title");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“main” org.openqa.selenium.WebDriverException 中的异常:未知错误:无法获得自动化扩展 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension 线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium 单击时无法确定加载状态错误 - Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status error while clicking using Selenium 线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium Java 的意外命令响应 - Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java org.openqa.selenium.WebDriverException:未知错误:无法使用ChromeDriver Selenium和Java聚焦元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element using ChromeDriver Selenium and Java org.openqa.selenium.WebDriverException:未知错误:无法通过Java用ChromeDriver Chrome和Selenium集中元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element with ChromeDriver Chrome and Selenium through Java 线程“ main” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:正常退出 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally 线程“主” org.openqa.selenium.WebDriverException中的异常:无法访问Chrome - Exception in thread “main” org.openqa.selenium.WebDriverException: chrome not reachable 线程“主”org.openqa.selenium.WebDriverException 中的异常:权限被拒绝 - Exception in thread “main” org.openqa.selenium.WebDriverException: permission denied 如何修复线程“主”org.openqa.selenium.WebDriverException 中的异常? - How to fix Exception in thread “main” org.openqa.selenium.WebDriverException? 线程“主” org.openqa.selenium.WebDriverException中的异常:未定义$ - Exception in thread “main” org.openqa.selenium.WebDriverException: $ is not defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM