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)));
1
  • 1
    What is element? Commented Aug 28, 2018 at 3:01

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

5 Comments

1. i tried this statement but still the same issue, wait.Until(ExpectedConditions.ElementExists(By.XPath(element)));
2. I believe i am using the right xpath, if i use Thread.Sleep(TimeSpan.FromSeconds(4)); it works correctly.
Error Message "org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..."
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.
@vignesh try waiting for the overlapping element to be not visible. I find that also tends to work in such scenarios
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.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.