1

Currently working with selenium remote driver. execution is working fine with Chrome remote driver but not working with IE. IE browser is launched after that NoSuchElementException displayed

similar issue I found at below url, I implemented all the specified solutions still not working for me. NoSuchElementException is occurred during implementation of InternetExplorerDriver in Selenium WebDriver

Launched Selenium grid - hub using: (Machine A) :

java -jar selenium-server-standalone-2.44.0.jar -role hub  

Launched Selenium grid - node using: (Machine B) :

java -jar selenium-server-standalone-2.44.0.jar -role webdriver -hub http://xx.x.xx.xx:4444/grid/register -port 5566 -browser browserName="internet explorer",version=8.0,platform=WINDOWS -Dwebdriver.ie.driver=\\SeleniumDrivers\IEDriverServer.exe

Code in the test script.(Eclipse)

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);    

//example code.

driver.get("www.google.com");
driver.findElement(By.id("gbqfqw")).sendKeys("test");
driver.findElement(By.name("btnG")).click();

During the Execution:

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'
Community
  • 1
  • 1
chandu k
  • 11
  • 5

2 Answers2

0

I've just tried your test on IE8, IE10 & IE11. On IE10 & IE11 everything works perfectly fine. IE8 will not work on google page because the buttons will be hidden under quick search results.

One possible explanation would be that in the example you have provided you are using "btnG" button. That button is made visible only after you type some text. Maybe you need to wait until button is displayed.

Can you do the test manually on your test machine and check if the "btnG" is actually there?

Update : All machines are VMs with appropriate version of IE installed. Test Machines are setup to start selenium server through

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 -port 4444

[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();
    }

}
milanio
  • 4,082
  • 24
  • 34
  • Hi milanio, i think you mis-understood the question , i got the problem when i execute in Remote driver. For cross check i have changed the remote driver to web driver and locally with IE browser script is passing without any issues. when i execute with the Remote driver only problem is occurring. – chandu k Feb 16 '15 at 17:25
  • Hi @chanduk, I've just updated the tests to run through remote webdriver (see above - test ClickSignInInInternetExplorerThroughRemoteDriver) and it passes for both IE8 & IE10. What version of IE is on the remote machine? Can you see the screen of that remote machine? Are you sure that button is actually there? – milanio Feb 17 '15 at 11:12
  • Hi @milano, I am using IE 11 with remote driver (configured using https://code.google.com/p/selenium/wiki/InternetExplorerDriver). I am able to see the screen of the remote driver. and driver.get statement is executed successfully. Google website i have given as example. – chandu k Feb 17 '15 at 12:22
  • Hi @chanduk, I'm changing the answer completely as the question is no longer related to CssSelectors. I've just run the tests with IE11 & IE10 and they pass on the google page. It will fail on IE8, because google page looks differently on IE8. – milanio Feb 17 '15 at 16:03
  • Hi milano, are you doing local execution or remote (i mean another different machine). For IE what are the settings you have done. also can you give the connection string to start the node. I have one doubt in your code, you did not specify which node you are executing. – chandu k Feb 18 '15 at 11:14
  • Hi @chanduk, xxx-xxx-tuai01,xxx-xxx-tuai02 & xxx-xxx-tuai04 are 3 different VM machines with different versions of IE (and OS) installed on them. Is that what you are asking for? RemoteDriver is initiated with URI to that VM(see TestCase attribute above the method.) – milanio Feb 18 '15 at 13:00
0

Thank you for the responses.

finally i found with two reasons why tests are failed in IE 11. Now resolved them

  1. Windows update KB3025390 causing the issue
  2. Added capabilities.setCapability("nativeEvents",false);

WebDriver test not running on IE11

Community
  • 1
  • 1
chandu k
  • 11
  • 5