gpt4 book ai didi

java - Selenium WebDriver 和 InternetExplorer

转载 作者:搜寻专家 更新时间:2023-11-01 01:13:52 25 4
gpt4 key购买 nike

我最近更新到 Selenium 2.24.1 以使 Firefox 13 正常工作。通过此更新,您现在可以运行类似于 chromedriver.exe 的可执行文件,以便它向 IE 发送事件。但是我没有运气让测试与 IE 一起运行。为了让它在 chrome 上运行,我显然还必须设置 webdriver.chrome.driver 位,但在它和 Firefox 中工作正常,代码相同。

这是我的源代码:

public class GoogleTest {

@Test
public void test() throws Exception {
System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
final WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
driver.findElement(By.name("q")).sendKeys("test");
driver.findElement(By.name("q")).submit();
driver.quit();
}

然而,在执行此测试时,我看到了这个堆栈跟踪

org.openqa.selenium.NoSuchElementException: Unable to find element with name == q (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 395 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_01'
Driver info: driver.version: RemoteWebDriver
Session ID: e20f8370-00ed-4bf6-a4fa-a0c09c2b6d8c
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:303)
at org.openqa.selenium.By$ByName.findElement(By.java:291)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)

最佳答案

这可能真的很明显,但是由于您在原始帖子中没有提到它并且您刚刚下载了驱动程序并且您的内部玩具应用程序正在运行,您是否仔细检查了 IEDriver 中提到的 IE 中的安全设置代码页:

On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".

如果您以前使用过以前版本的 Selenium,您可能已经这样做了,但我认为值得检查一下以确保...

关于java - Selenium WebDriver 和 InternetExplorer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11157902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com