I am facing a challenge where I need to gather multiple links, click on each link, and extract specific information from the website to export into Excel. My approach involves collecting all the links in one list and attempting to click on each one based on their index. Despite not encountering any exceptions, the click action is not being executed on the elements. I am currently stuck in trying to click on a link using a JavaScript executor. The normal click and actions methods are proving unsuccessful in this scenario.
List<WebElement> titles=driver.findElements(By.xpath("//*[@class='product-name']"));
for(int i=0;i<titles.size();i++)
{
String title1=titles.get(i).getText();
System.out.println(title1);
Thread.sleep(5000);
if(titles.get(i).isEnabled())
{
System.out.println("TAKE ACTION");
js.executeScript("arguments[0].click();", titles.get(i));
}
}