driver.findElement(By.xpath("(//a[@value='DEL'])[1]")).click();
no such element: Unable to locate element: {"method":"xpath","selector":"(//a[@value='DEL'])[1]"}
(Session info: chrome=138.0.7204.168)
Getting above error
Here is my code : I need toselect Chennai in Destination but nothing workedout
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
public class DropDown {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver = new ChromeDriver();
driver.get("http://spicejet.com"); // URL in the browser
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
// //a[@value='MAA'] - Xpath for chennai
// //a[@value='BLR']
// Dynamic Drop down
driver.findElement(By.xpath(
"//div[@class= 'css-1dbjc4n r-14lw9ot r-11u4nky r-z2wwpe r-1phboty r-rs99b7 r-1loqt21 r-13awgt0 r-ymttw5 r-tju18j r-5njf8e r-1otgn73']"))
.click();
driver.findElement(By.xpath("//div[contains(text(), 'Bengaluru')]")).click();
Thread.sleep(2000);
// driver.findElement(By.xpath("(//a[@value='MAA'])[2]")).click();
driver.findElement(By.xpath("//div[text()='To']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("(//a[@value='DEL'])[1]")).click();
/*
* WebElement chennaiOption = driver.findElement(By.xpath(
* "(//*([@class='css-1dbjc4n']//div[text()='Chennai'])")); Actions actions =
* new Actions(driver); actions.moveToElement(chennaiOption).click().perform();
*/
// driver.findElement(By.xpath("//div[text()='Chennai']")).click();
// driver.findElement(By.xpath("//div[@data-testid='dropdown-group']//div[text()='Chennai']")).click();
// driver.findElement(By.cssSelector("a[value='MAA']")).click();
// driver.findElement(By.xpath("//div[@data-testid='search-destination-city-txt']//div[text()='Chennai']")).click();
// driver.findElement(By.xpath("(//div[text()='Chennai'])[1]")).click();
// driver.findElement(By.xpath("(//*[@class='css-1dbjc4n']//div[text()='Chennai'])[1]")).click();
}
}