Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium: Get all text with same id
    text
    copied!<p>The Xpath of the elements I want to read (Accounting, Business, Marketing, Technology) are as follows:</p> <pre><code>/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[2]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr/td[4]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[2]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[4]/font/a </code></pre> <p>The id for all of the elements is</p> <pre><code>//font[@class='wlCategoryLinkBold']/a </code></pre> <p>The page I am testing is similar to the following:</p> <p><img src="https://i.stack.imgur.com/OwLwF.jpg" alt="enter image description here"></p> <p>I have the following test method:</p> <pre><code>public void ListAllLinksInArray() { SelObj = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost/crm.aspx"); SelObj.Start(); SelObj.Open("http://localhost/crm.aspx"); SelObj.SelectFrame("content"); List&lt;string&gt; topics = new List&lt;string&gt;(); int count = (int)SelObj.GetXpathCount("//font[@class='wlCategoryLinkBold']/a"); for (int i = 1; i &lt;= count; i++) { if (SelObj.IsElementPresent("//font[@class='wlCategoryLinkBold']/a")) { string value = SelObj.GetText("//font[@class='wlCategoryLinkBold']/a[" + i + "]"); topics.Add(value); } } string[] arrTopics = topics.ToArray(); System.IO.File.WriteAllLines(@"C:\WriteLines.txt", arrTopics); } </code></pre> <p>The above code only writes Accounting (once) in the text file.</p> <p>If I do:</p> <pre><code>string value = SelObj.GetText("//font[@class='wlCategoryLinkBold']/a"); </code></pre> <p>I get Accounting (4 times) in the text file. </p> <p>What is wrong in the loop that is not printing all four links in the text file. Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload