Reputation: 1
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)));
Upvotes: 0
Views: 137
Reputation: 472
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.
Upvotes: 0
Reputation: 1
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.
Upvotes: 0
Reputation: 139
There could be 2 issues here:
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.
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.
Upvotes: 4