The actual test is to go onto ebay, click on the searchbox, type in "iphone 8", then enter, and then click on the product with the highest amount of product ratings. Here is my code so far
`WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.get("https://www.ebay.com/");
driver.manage().window().maximize();
driver.findElement(By.id("gh-ac")).sendKeys("iphone 8", Keys.ENTER);`
The issue here is that the webelement that shows the product reviews isn’t the same webelement as the one we need to click on to get on to the product page.
2
Answers
Try to find elements with xPath.
Below is an example of the first 2 full xPaths for the iPhone 8 found on eBay search results.
I am seeing a pattern up to the
/li[x]
You can iterate through the whole list of products on that page and set each product into an object with a link and product review attribute so you can then further process the data.
Please see the below code and let me know if you face any problem.
Please do let me now if you face any issue executing the above code.