Find All Links By Class With Selenium
On the web page there are a few articles. I need to get links to all articles. I use Selenium and Powershell. I do a search with: FindElementByXPath('//*[contains(@class, 'without
Solution 1:
I don't know anything about Powershell
But Using java with selenium
you can do this like below mentioned code.
I know it's not a proper answer to deal with, but below code will give you the hint
, that how you should go with other language.
List<WebElement> links = driver.findElements(By.className("without")); // Using list web-element get all web-elements, whose classname name as "without"
System.out.println(links.size()); //total number of links on the page.for(int i = 0;i<links.size();i++)
{
System.out.println(links.get(i).getAttribute("href")); //Using for loop getting one by one links name.
links.get(i).click(); // click the link if you want to click
Thread.sleep(2500); //wait for 2.5 seconds
}
Hope my above answer will help you.
Post a Comment for "Find All Links By Class With Selenium"