driver.FindElement(By.Id("diagnosisivd")).Click();
While running above code getting error:
"main" org.openqa.selenium.NoSuchElementException: no such element
As I have written correct id
.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communitydriver.FindElement(By.Id("diagnosisivd")).Click();
While running above code getting error:
"main" org.openqa.selenium.NoSuchElementException: no such element
As I have written correct id
.
First correct your syntax error:
driver.findElement(By.id("diagnosisivd")).click();
If this is correct and still your are facing the same then try by adding some wait at some conditions.
WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("diagnosisivd")));
Try with different locator type XPath/CSSSelector-
By.xpath : //*[@id='diagnosisivd']
Even if I don't know anything about it, what you can try is to run the test in debug mode and set a breakpoint on that instruction. If once you run it you wait some time before executing the instruction in the breakpoint and it works, then it's a matter of timing. Probably the element is not there yet when you try to click on it. Otherwise you can put an explicit wait for something like 5 seconds before that instruction and check if it works. If it works, remove the explicit wait and make the wait depending on the presence and clickability of that element.