这些是我的代码正在运行的步骤。
我使用安全shell appt启动chromedriver - 没问题,它启动浏览器并正确启用
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);
然后我使用驱动程序导航到chrome URL设置页面以发送连接数据。
driver.get("chrome-extension://pnhechapfaindjhompbnflcldabbghjo/html/nassh.html");
在下面这张图片的页面上,我尝试发送密钥或点击任何带有sendkeys的字段或点击,我收到以下错误。 我尝试了多种方法,并获得相同的结果:org.openqa.selenium.WebDriverException:未知错误:无法设置属性'value'为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并收到了相同的结果。思考
Breift描述:终端仿真器和SSH客户端。
Secure Shell是一个xterm兼容的终端模拟器和Chrome的独立ssh客户端。它使用Native-Client直接连接到ssh服务器,而无需外部代理。
https://chrome.google.com/webstore/detail/secure-shell-extension/iodihamcpbpeioajjeobimgagajmlibd
答案 0 :(得分:1)
从https://sites.google.com/a/chromium.org/chromedriver/downloads
将ChromeDriver更新为2.37(最新版本)我认为您使用的是Chrome v65
答案 1 :(得分:0)
问题与框架有关。我用这段代码确定了多少帧,然后将密钥发送到正确的帧。唷!
int size = driver.findElements(By.tagName("iframe")).size();
System.out.println(size);
driver.switchTo().frame(1); // Switching the inner Frame with 1 0 for outer fram
driver.findElement(By.xpath("//*[@id='field-description']")).sendKeys("9109");