Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98757

Selecting all links under only one div

$
0
0

I am trying to select all of the links contained under this one div in this kind of structure:

<div id = "logged_hits">
   <div class="toHigh nl">
     <a href="(link i want to click)">/a>
   </div>
</div>

I am trying to click all the links under the "logged_hits" id since the structure of the html contains many links under this one div. I am selecting the div by its XPath here:

 List<IWebElement> allLinks = driver.FindElements(By.XPath("/html/body/div[6]")).ToList();

Then looping through each element in the list

        foreach (var value in allLinks)
        {
            Console.WriteLine(value.GetAttribute("href").ToString());
        }

I get no values since I dont think it can find the a tags. Any help would be greatly appriciated


Viewing all articles
Browse latest Browse all 98757

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>