Issue
I am trying to simply click on the dropdown list that is displayed after I enter the word advance. But I keep getting an error being thrown. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:
public void supplier (WebDriver driver)
{
Actions action = new Actions(driver);
WebElement supplierLink = driver.findElement(By.id("_searchstring"));
supplierLink.sendKeys("Advance");
//*[@id="/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108"]
//WebDriverWait wait = new WebDriverWait(driver, 5);
//wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108")));
WebElement clickadvance = driver.findElement(By.id("/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108"));
action.moveToElement(clickadvance).perform();
}
Solution
Please add wait conditions in your code, this will work,
WebDriverWait wait = new WebDriverWait(driver, 20);
By optionXpath = By.id("/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108");
wait.until(ExpectedConditions.elementToBeClickable(optionXpath));
driver.findElement(optionXpath).click();
if not your xpath is wrong, change the xpath accordingly.
Answered By - Jayanth Bala