In this video will see how to resolve selenium error – Exception in thread “main” org.openqa.selenium. UnexpectedTagNameException: Element should have been “select” but was “div”.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Code:
driver.get("https://www.booking.com/");
driver.findElement(By.xpath("//a[@data-decider-header='flights']")).click();
driver.findElement(By.xpath("//div[@class='css-1ntod47']")).click();
WebElement staticDropdown = driver.findElement(By.xpath("//select[@class='css-1k0jlfl']"));
Select dropDown = new Select(staticDropdown);
dropDown.selectByIndex(1);
dropDown.selectByVisibleText("Business");
dropDown.selectByValue("FIRST");
Error screenshot:
