Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.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 Selenium远程驱动程序-在InternetExplorerDriver的实现过程中发生NoTouchElementException_Java_Eclipse_Selenium_Internet Explorer_Screenshotexception - Fatal编程技术网

Java Selenium远程驱动程序-在InternetExplorerDriver的实现过程中发生NoTouchElementException

Java Selenium远程驱动程序-在InternetExplorerDriver的实现过程中发生NoTouchElementException,java,eclipse,selenium,internet-explorer,screenshotexception,Java,Eclipse,Selenium,Internet Explorer,Screenshotexception,目前正在使用selenium远程驱动程序。使用Chrome远程驱动程序执行正常,但不使用IE。IE浏览器在显示NoTouchElementException后启动 我在下面的url中发现了类似的问题,我实现了所有指定的解决方案,但仍然不适用于我。 已启动Selenium网格-集线器使用:机器A: 已启动Selenium网格-节点使用:机器B: 测试脚本中的代码 DesiredCapabilities capabilities = DesiredCapabilities.internetExpl

目前正在使用selenium远程驱动程序。使用Chrome远程驱动程序执行正常,但不使用IE。IE浏览器在显示NoTouchElementException后启动

我在下面的url中发现了类似的问题,我实现了所有指定的解决方案,但仍然不适用于我。

已启动Selenium网格-集线器使用:机器A:

已启动Selenium网格-节点使用:机器B:

测试脚本中的代码

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setBrowserName("internet explorer");
capabilities.setPlatform(Platform.WINDOWS);             
capabilities.setCapability("ie.ensureCleanSession", true);    
capabilities.setCapability("forceCreateProcessApi", true);
capabilities.setCapability("ignoreProtectedModeSettings", true);
System.setProperty("webdriver.ie.driver", "\\SeleniumDrivers\\IEDriverServer.exe");
WebDriver driver = new RemoteWebDriver(new URL("http://MachineBIPAddress:5566/wd/hub"),capabilities);    
//示例代码

driver.get("www.google.com");
driver.findElement(By.id("gbqfqw")).sendKeys("test");
driver.findElement(By.name("btnG")).click();
执行期间:


我刚刚试过你在IE8、IE10和IE11上的测试。在IE10和IE11上,一切都很好。IE8不会在谷歌页面上运行,因为按钮将隐藏在快速搜索结果下

一种可能的解释是,在您提供的示例中,您使用的是btnG按钮。只有在键入一些文本后,该按钮才可见。也许您需要等到按钮显示出来

您能在您的测试机器上手动执行测试并检查btnG是否确实存在吗

更新:所有机器都是安装了适当版本IE的虚拟机。测试机器设置为通过启动selenium服务器

javaw.exe-Dwebdriver.chrome.driver=chromedriver.exe -Dwebdriver.ie.driver=IEDriverServer.exe-Dphantomjs.binary.path=phantomjs.exe-jar selenium-server-standalone-2.41.0.jar-端口4444


谢谢你的回复

最后,我找到了IE11测试失败的两个原因。现在解决了这些问题

导致此问题的Windows update KB3025390 添加了功能。setCapabilitynativeEvents,false;
忽略ProtectedModeSettings,请在进行任何调试之前删除此项。您好,米兰尼奥,我想您误解了这个问题,我在远程驱动程序中执行时遇到了这个问题。为了进行交叉检查,我已将远程驱动程序更改为web驱动程序,并在本地使用IE浏览器脚本进行传递,没有任何问题。当我使用远程驱动程序执行时,只会出现问题。Hi@chanduk,我刚刚更新了通过远程webdriver运行的测试,请参见上文-测试单击SigningInInternetExplorerThroughRemoteDriver,它将通过IE8和IE10。远程计算机上有什么版本的IE?你能看到那台远程机器的屏幕吗?你们确定那个按钮真的在那个里吗?嗨@milano,我使用的是IE11,远程驱动程序配置使用。我能看到遥控器驱动程序的屏幕。并且driver.get语句已成功执行。我举的谷歌网站为例。嗨@chanduk,我完全改变了答案,因为这个问题不再与CSSSelector相关。我刚刚用IE11和IE10运行了测试,它们通过了google页面。它会在IE8上失败,因为谷歌页面在IE8上看起来不同。嗨,米兰,你是在做本地执行还是远程执行?我是说另一台不同的机器。对于IE,您所做的设置是什么。您还可以指定用于启动节点的连接字符串。我对您的代码有一个疑问,您没有指定要执行的节点。
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setBrowserName("internet explorer");
capabilities.setPlatform(Platform.WINDOWS);             
capabilities.setCapability("ie.ensureCleanSession", true);    
capabilities.setCapability("forceCreateProcessApi", true);
capabilities.setCapability("ignoreProtectedModeSettings", true);
System.setProperty("webdriver.ie.driver", "\\SeleniumDrivers\\IEDriverServer.exe");
WebDriver driver = new RemoteWebDriver(new URL("http://MachineBIPAddress:5566/wd/hub"),capabilities);    
driver.get("www.google.com");
driver.findElement(By.id("gbqfqw")).sendKeys("test");
driver.findElement(By.name("btnG")).click();
IE browser is launched in Machine B and then error "org.openqa.selenium.NoSuchElementException:" displayed.


log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == a[class*='searchbtn'] (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.13 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'xxxxxxx', ip: 'xxx.xx.xx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=true, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:27297/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 445a8c44-fb7c-4f05-8b5a-f025787ffea5
Command duration or timeout: 23.98 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
System info: host: 'xxxxxx', ip: 'xx.x.xxx.xx', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=true, elementScrollBehavior=0, ie.browserCommandLineSwitches=, webdriver.remote.sessionid=5daa42d6-5f04-46ac-821a-59dcb261edd1, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:27297/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 5daa42d6-5f04-46ac-821a-59dcb261edd1
    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:408)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:441)
    at org.openqa.selenium.By$ByCssSelector.findElement(By.java:426)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
    at dashBoard_Automation.dashboardSerach.main(xxxx.java:86)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
[TestCase("IE8", "http://xxx-xxx-tuai04:4444/wd/hub")]
[TestCase("IE10", "http://xxx-xxx-tuai01:4444/wd/hub")]
[TestCase("IE11", "http://xxx-xxx-tuai02:4444/wd/hub")]
public void ClickSignInInInternetExplorerThroughRemoteDriver(string version, string url)
{
    using (var driver = new RemoteWebDriver(new Uri(url), DesiredCapabilities.InternetExplorer()))
    {

        driver.Navigate().GoToUrl("https://www.google.com/?gws_rd=cr,ssl&fg=1");
        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

        var element = driver.FindElementById("gbqfqw");
        element.SendKeys("test");

        var btn = driver.FindElementByName("btnG");
        btn.Click();
    }

}