0

I am using:

  • Selenium version 4.3.0
  • IE Driver 4.3.0 (32 bit)
  • Edge Version 103.0.1264.71
  • Java (JRE 1.8)

I'm attempting to get a simple Edge driver in IE mode example working, that is exactly from the Microsoft website https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ie-mode?tabs=java#the-complete-sample

Only additional line is the added IE driver property

System.setProperty("webdriver.ie.driver", C:\\Downloads\\IEDriverServer_Win32_4.3.0\\IEDriverServer.exe");

I have also gone through all the Selenium IE Driver configurations here: https://www.selenium.dev/documentation/ie_driver_server/#required-configuration

I am now at a point where Edge launches in IE mode, appears to load the driver and page correctly, but attempting to find an element on the page (either by id or xpath) results in an error.

Error output:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Started InternetExplorerDriver server (32-bit)
4.3.0.0
Only local connections are allowed
Jul. 26, 2022 4:29:55 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
Jul. 26, 2022 4:29:55 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
WARNING: Support for Legacy Capabilities is deprecated; You are sending the following invalid capabilities: [ie.edgechromium, ie.edgepath]; Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #sb_form_q
For documentation on this error, please visit: https://selenium.dev/exceptions/#no_such_element
Build info: version: '4.3.0', revision: 'a4995e2c09*'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Command: [5d0f617f-9996-4877-a367-834c673c819a, findElement {using=id, value=sb_form_q}]
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.edgechromium: true, ie.edgepath: C:\Program Files (x86)\Micr..., ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: false, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:64126/, nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 5d0f617f-9996-4877-a367-834c673c819a
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElement(ElementLocation.java:162)
    at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:66)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:387)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:379)
    at junk.main(junk.java:22)

I am unsure why I am getting the line:

You are sending the following invalid capabilities: [ie.edgechromium, ie.edgepath];

as it is directly from the example and I've ensured the framework versions are all correct (as far as I can tell).

I don't have any idea why it is unable to find the element, even with a short sleep after creating the driver.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
S8e
  • 1

1 Answers1

0

This error message...

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #sb_form_q

...implies that NoSuchElementException was raised while searching for the desired WebElement.


Solution

Ideally, to send a character sequence to the Search Box field within the website as the element is a dynamic element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategies:

  • Using name:

    driver.get("https://www.bing.com/");
    new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.name("q"))).sendKeys("WebDriver", Keys.RETURN);
    
  • Using cssSelector:

    driver.get("https://www.bing.com/");
    new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.sb_form_q"))).sendKeys("WebDriver", Keys.RETURN);
    
  • Using xpath:

    driver.get("https://www.bing.com/");
    new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='sb_form_q']"))).sendKeys("WebDriver", Keys.RETURN);
    
  • Browser Snapshot:

bing_search

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks, however I am now receiving this error ```Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //input[@id='sb_form_q'] (tried for 10 second(s) with 10000 milliseconds interval)``` It appears as though we're losing connection or unable to communicated with the driver after it is launched, and subsequent commands are ignored – S8e Jul 26 '22 at 21:26
  • How about using _NAME_ and _CSS_? – undetected Selenium Jul 26 '22 at 21:28
  • No difference if using css, name or xpath. I do not believe the selection criteria to be the issue – S8e Jul 26 '22 at 21:28
  • Honestly, even we don't know your configuration settings, typical guesswork as per _**NoSuchElementException**_ – undetected Selenium Jul 26 '22 at 21:32