0

I am using Visual Studio Selenium with C# to select a menu option currently I using Chrome but I will be using multiple browsers. Here is the code I am using:

{
    var dropdown = driver.FindElement(By.CssSelector(".row:nth-child(5) > .col-md-3 > .input-group > .form-control"));
    dropdown.FindElement(By.XPath("//option[. = 'Slight']")).Click();
}

I have put threads in to slow down the test and keep getting the following error. Message:

OpenQA.Selenium.ElementNotInteractableException : element not interactable: Element is not currently visible and may not be manipulated

  (Session info: chrome=79.0.3945.117)

Stack Trace:

RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
RemoteWebElement.Click()
ChromeResizeEditThrusterTest.chromeResizeEditThruster() line 75
Joel
  • 5,732
  • 4
  • 37
  • 65
  • See https://stackoverflow.com/questions/10641535/how-i-can-avoid-element-is-not-currently-visible-and-so-may-not-be-interacted-w/16162026 –  Jan 10 '20 at 00:27

1 Answers1

0

First of all when you trying to click on some web element make sure that element is currently visible on the screen, if not, try to scroll the page to the position of the element:

var element = driver.FindElement(By.Id("your_element_id"));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);
Thread.Sleep(1000);

Also for easily manage specific web elements try to use Selenium.Support, for example:

var webElemnt = driver.FindElement(By.Id("your_dropdown_id"));
var dropdown = new SelectElement(webElemnt);
dropdown.Options[1].Click();
Serhii Matvienko
  • 292
  • 3
  • 15
  • First I am not using a JavaScript executable. Second all of the elements are available when I go into it manually I can see all of the menu options and they are able to be clicked on without any issues. Another point I used a Thread.Sleep(10000); Just to make sure it wasn't the script moving to fast. – Largent803 Jan 10 '20 at 16:03