Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “线程中的异常”;“主要”;org.openqa.selenium.WebDriverException:未知错误:无法聚焦元素_Java_Macos_Google Chrome_Selenium Webdriver - Fatal编程技术网

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

Java “线程中的异常”;“主要”;org.openqa.selenium.WebDriverException:未知错误:无法聚焦元素,java,macos,google-chrome,selenium-webdriver,Java,Macos,Google Chrome,Selenium Webdriver,我一直在尝试使用Selenium sendkeys(),但在使用Chrome时没有成功。我在这里研究过类似的问题,但似乎没有成功。我可以生成URL、调用按钮(单击()),但当我尝试在特定文本字段中输入值时,我会得到: 线程“main”org.openqa.selenium.WebDriverException中出现异常:未知错误:无法聚焦元素 非常感谢您的帮助。谢谢大家! 下面是一段代码: WebElement titleBox = driver.findElement(By.xpath("//

我一直在尝试使用Selenium sendkeys(),但在使用Chrome时没有成功。我在这里研究过类似的问题,但似乎没有成功。我可以生成URL、调用按钮(单击()),但当我尝试在特定文本字段中输入值时,我会得到:

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

非常感谢您的帮助。谢谢大家!

下面是一段代码:

WebElement titleBox = driver.findElement(By.xpath("//*[@id='root']/div/div[2]/div/div/div[2]/div[1]"));
titleBox.click();
titleBox.sendKeys("Test Survey Title");
以下是堆栈跟踪:

端口43615上的启动ChromeDriver 2.29.461585(0BE2CD95F834E9EE7C46BC7CF405B483F5AE83B) 只允许本地连接。 2017年5月26日下午3:42:50 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:OSS 线程“main”org.openqa.selenium.WebDriverException中出现异常:未知错误:无法聚焦元素 (会话信息:chrome=58.0.3029.110) (驱动程序信息:chromedriver=2.29.461585(0BE2CD95F834E9EE7C46BC7CF405B483F5AE83B),平台=Mac OS X 10.12.5 x8664)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:43毫秒 生成信息:版本:“3.4.0”,版本:“未知”,时间:“未知” 系统信息:主机:'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' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能[{applicationCacheEnabled=false,rotatable=false,mobileEmulationEnabled=false,networkConnectionEnabled=false,chrome={chromedriverVersion=2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),userDataDir=/var/folders/55/jxcw642x4593njd3nnysck_8000GN/T/.org.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,WebStorage=true,browserName=chrome,TakesScreensShot=true,javascriptEnabled=true,cssSeLectorEnabled=true,unexpectedAlertBehaviour=}] 会话ID:C0D55118BF095A12CB6E105B58B149E 位于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.CreateTrowable(ErrorHandler.java:215) 位于org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167) 位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671) 位于org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272) 位于org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96)
在LaunchChrome.main(LaunchChrome.java:36)

中,您可以尝试使用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");

当我回顾这个问题时,我在一篇不同的帖子中看到了可能的重复。不幸的是,这对我不起作用。我似乎无法克服“无法集中注意力”的问题。也许应该,但对我来说不是。对Selenium有点失望,首先我在IDE中遇到了类似的问题,当时我可以让页面做我想做的事情,但无法让“sendkeys”或“type”输入值,所以我决定给webdriver一个使用chrome的机会。。。我在这里。无论如何,各位,谢谢你们的宝贵意见。和平。