0

The below code is not working and it always throws No such element exception at line 2.

wait.IgnoreExceptionTypes(typeof(NoSuchElementException));      
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(element)));
Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
vignesh
  • 1
  • 1

3 Answers3

4

There could be 2 issues here:

  1. You are trying to find the element before its visible for that you can wait for the element by doing

    wait.Until(ExpectedConditions.ElementExists(By.XPath(element)));
    

    where element is the XPath of the element you are trying to find.

  2. You are not finding the element using the correct XPath. If you are using an absolute XPath, avoid doing because while absolute XPath can find the element faster, if the DOM structure changes your path may no longer work.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
mfy316
  • 129
  • 10
  • 1. i tried this statement but still the same issue, wait.Until(ExpectedConditions.ElementExists(By.XPath(element))); – vignesh Aug 28 '18 at 04:45
  • 2. I believe i am using the right xpath, if i use Thread.Sleep(TimeSpan.FromSeconds(4)); it works correctly. – vignesh Aug 28 '18 at 04:46
  • Error Message "org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..." – vignesh Aug 28 '18 at 04:51
  • so the issue here is that there is an overlay over the element you are trying to click . One way to solve this problem is to create a new actions object using Action Ex: Actions action = new Actions(webdriver); then you do action.MoveToElement(element).Click().Perform(); this exception happens when there are hidden overlays on elements. – mfy316 Aug 28 '18 at 06:40
  • @vignesh try waiting for the overlapping element to be not visible. I find that also tends to work in such scenarios – Taran Aug 28 '18 at 07:48
0

It is also possible that you are not running your browser in fullscreen, at least this was a valid issue I was facing when my current projects' GUI got changed over. Adding driver.Manage().Window.Maximize(); to my ClassInitialize fixed the issue in a whim.

Another option is that maybe your element is either embedded into an iframe or is overlapped by one.

crawenn
  • 1
  • 1
0

As mentioned in this answer https://stackoverflow.com/a/44724688/6045154 , I have solved a similar issue with:

IWebElement button = driver.FindElement(By.ClassName("transfer__button")); IJavaScriptExecutor executor = (IJavaScriptExecutor)driver; executor.ExecuteScript("arguments[0].click();", button);

Of course this needs to be edited to find your element by the right selector.

AsheraH
  • 474
  • 10
  • 15