question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🐛 Bug]: Open.Selenium.InvalidStateException was occurred using IE.

See original GitHub issue

What happened?

Open.Selenium.InvalidStateException was occurred using IE.

For details and reproduction methods, I wonder if you check items after ‘How can we reproduce the issue?’.

This exception is occured at InternetExplorerDriver, is not occured at EdgeDriver.

I test this 👆 change to EdgeDriver class from InternetExplorerDriver class, test has all passed.

Sorry for my poor english, thank you.

How can we reproduce the issue?

The implementation is like this:


private readonly IWebDriver _webDriver; // selenium process run class field.

...

public ctor(string webDriverDirectoryPath)
{
    // get webdriver directory absolute path from ctor argument.
    _webDriver = new InternetExplorerDriver(webDriverDirectoryPath);
}

public void Init()
{
  // this method is navigating method for looping invoke method page.
}

// this method called by other class using foreach.
public void Invoke(TestCase testCase)
{
    ...

    _webDriver
        .FindElement(By.Id("{Input html tag id}"))
        .Clear();  // error has occurred this point.
    _webDriver
        .FindElement(By.Id("{Input html tag id}"))
        .SendKeys(testCase.Value);

    ...

    var selectElement = new SelectElement(_webDriver
        .FindElement(By.Id("{Select html tag id}"))
    );
    selectElement.SelectByIndex(testCase.SelectIndex);  // this method not work. however using for loop and SendKey(Keys.ArrowDown) is work.
}


That👆 code runnning at Xunit testing.

```cs
var testCases = new[]
{
    new TestCase(1, 1, "hoge", "001", "51000", "Yamada"),
    new TestCase(2, 1, "fuga", "002", "51001", "Tanaka"),
    new TestCase(3, 1, "piyo", "003", "51002", "Suzuki")
};

using var invoker = new SeleniumInvoker();
invoker.Init();

var result1 = invoker.Invoke(testCases[0]);
Assert.Equal("OK", result1.CheckResult);
Assert.Equal("Yamada", result1.CustomerName);
Assert.Empty(result1.ErrorMessages);

var result2 = invoker.GetResult(testCases[1]);
Assert.Equal("NG", result2.CheckResult);
Assert.Equal("Tanaka", result2.CustomerName);
Assert.Equal("Invalid Code", result2.ErrorMessages.Single());

var result3 = invoker.GetResult(testCases[2]);
Assert.Equal("NG", result3.CheckResult);
Assert.Equal("Suzuki", result3.CustomerName);
Assert.Equal("No Account", result3.ErrorMessages.Single());


### Relevant log output

```shell
Xunit failed message:

OpenQA.Selenium.InvalidElementStateException
A JavaScript error was encountered clearing the element. The driver assumes this is because the element is hidden, disabled or read-only, and it must not be to clear the element.
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebElement.Execute(String commandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebElement.Clear()


### Operating System

Windows 10, Version 21H1 , OS Build 19043.1706

### Selenium version

C#, Selenium.Support 4.1.1, Selenium.WebDriver 4.1.1

### What are the browser(s) and version(s) where you see this issue?

Internet Explorer Version 21H1 (OS Build 19043.1706)

### What are the browser driver(s) and version(s) where you see this issue?

IEDriverServer.exe 4.0.0.0 (64-bit)

### Are you using Selenium Grid?

_No response_

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
titusfortnercommented, Jun 1, 2022

If you reload the page as part of the loop does it work? Somehow the driver sees it as being in a state that won’t work, and without something consistent that we can reproduce, it will be very difficult for us to see why it happens.

0reactions
github-actions[bot]commented, Jul 24, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java lang IllegalStateException Error after adding set property ...
I am getting Exception: in thread "main" java.lang. ... driver executable must be set by the webdriver.chrome.driver. system property;.
Read more >
How to Resolve session not created Exception i.e. ... - YouTube
This video shows how to fix “Exception in thread "main" org.openqa. selenium.SessionNotCreatedException: session not created: This version of ...
Read more >
Unable to launch IE browser - IllegalStateException while ...
As per provided code, you used Capital 'W' in setProperty. In thrown exception it saying use. 'webdriver.ie.driver'.
Read more >
Solution for java.lang.illegalstateexception in Selenium ...
Today in this article we are going to discuss one exception which everyone has faced while working with other browsers. By default, Selenium...
Read more >
How to fix common Selenium errors? - Ultimate QA
This error occurred to me with: Chrome 55,56. ChromeDriver 2.27; Selenium WebDriver 3.0.1. The Solution. Use ChromeDriver for all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found