Verify Search Results

How to verify search results corresponding to entered keyword?
Suppose you entered "Shirts" in Amazon search field then how you can verify that search result are relevant to "shirts"?

Showing Answers 1 - 1 of 1 Answers

Venkata Bharadwaj Racherla

  • Mar 27th, 2017

  1.  WebDriver driver = new FirefoxDriver();

  2.             driver.get("http://[domain name]");

  3.             driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

  4.             Actions action = new Actions(driver);

  5.             WebElement search = driver.findElement(By.xpath(".//*[@id=twotabsearchtextbox]"));


  7.             //Search using actions by combining entering search string and then hit enter

  8.   "Shirt").sendKeys(Keys.RETURN).build().perform();


  10.             // This also works where it does the same without actions class

  11.             search.sendKeys("Shirt");

  12.             search.sendKeys(Keys.RETURN);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions