这些是我的代码运行的步骤。
我使用安全 shell appt 启动 chromedriver - 没有问题,它可以正确启动浏览器和 appt
chromeOptions.addExtensions(new File("src/test/resources/win32/browserprofile/Secure-Shell-App_v0.8.43.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
然后,我使用 driver get 导航到 chrome URL 设置页面以发送连接数据。
driver.get("chrome-extension://pnhechapfaindjhompbnflcldabbghjo/html/nassh.html");
在下图中的此页面上,我尝试发送 key 或单击带有 sendkeys 的任何字段或单击,但出现以下错误。 我尝试了多种方法,但得到了相同的结果:org.openqa.selenium.WebDriverException:未知错误:无法设置 null 的属性“值”
这是我的代码
//Webdriver
driver.findElement(By.xpath("//*[@id='field-description']")).sendKeys("aabb");
driver.findElement(By.id("field-username")).click();
driver.findElement(By.id("field-username")).sendKeys("useridval");
driver.findElement(By.id("field-hostname")).click();
driver.findElement(By.id("field-hostname")).sendKeys("10.0.0.0");
//JavascriptExecutor
// This will execute JavaScript in your script
((JavascriptExecutor)driver).executeScript("document.getElementById('field-username').value='migsrcrfuser';");
问题:这可能吗,我看到一个 id 并且该 id 是唯一的;此外,我还尝试了xpath并收到了相同的结果。感想
简要描述:终端仿真器和 SSH 客户端。 Secure Shell 是一个与 xterm 兼容的终端模拟器和适用于 Chrome 的独立 ssh 客户端。它使用 Native-Client 直接连接到 ssh 服务器,无需外部代理。 https://chrome.google.com/webstore/detail/secure-shell-extension/iodihamcpbpeioajjeobimgagajmlibd
最佳答案
将您的 ChromeDriver 从 https://sites.google.com/a/chromium.org/chromedriver/downloads 更新到 2.37(最新)
我认为您使用的是 Chrome v65
关于java - 无法使用 selenium Java 或 JavascriptExecutor 发送按键/单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49547881/