Gaurav Kumar
Gaurav Kumar

Reputation: 11

Why is Selenium not able to identify the WebElement?

I am trying to press the + icon present under Bedrooms. I even hard-coded a 5 seconds wait. The last line throws element not found exception. Please, help me.

driver.get("https://www.tripadvisor.in/VRACSearch-g294207-Reviews-Nairobi-Vacation_Rentals.html");
    
    driver.findElement(By.xpath("//div[@class='_2uJXqhFj']")).click();
    Thread.sleep(5000);
    driver.findElement(By.xpath("//body/div[14]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[2]/span[2]/span[1]")).click();

Upvotes: 1

Views: 48

Answers (2)

itronic1990
itronic1990

Reputation: 1441

Try this: .//div[text()='Bedrooms']//following-sibling::div/span/span[contains(@class,'ui_icon plus')]

Upvotes: 1

vitaliis
vitaliis

Reputation: 4212

Try using css selector for this icon:

._1laeAPbS:nth-of-type(1) .plus

Upvotes: 0

Related Questions