1
<div id="ctl00_ContentHolder_vs_ValidationSummary" class="errorblock">
    <p><strong>The following errors were found:</strong></p>
    <ul><input type="hidden" Name="SummaryErrorCmsIds" Value="E024|E012|E014" />
        <li>Please select a title.</li>
        <li>Please key in your first name.</li>
        <li>Please key in your last name.</li>
    </ul>
</div>

I want to capture the text having value of E024 E012 and E014 and write it in to an Excel file.

I tried the following but it doesn't work.

string val1 = driver.FindElement(By.XPath("//div[contains(@class, 'errorblock'/ value = 'E024|E012|E014'")).Text;

How can I do this?

Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272
user1603518
  • 41
  • 1
  • 1
  • 6
  • I don't understand what do you want to capture? The value of 'Value' parameter? Or something else? – JacekM Aug 21 '12 at 23:00
  • Yes I want to capture the value of Value ie Please select a title , Please key in your first name and Please key in your last name . These value to be captured and write it in to excel – user1603518 Aug 22 '12 at 08:22

6 Answers6

1

In java -

String x = driver.findElement(By.name("SummaryErrorCmsIds")).getAttribute("Value"));
some_other_guy
  • 3,364
  • 4
  • 37
  • 55
  • Hi I tried getting only the null value in String X. can you please suggest any other way ? – user1603518 Aug 22 '12 at 08:46
  • Yes the name is correct , you can see my html code in the question.I want to capture the value of Value ie Please select a title , Please key in your first name and Please key in your last name . These value to be captured and write it in to excel. But string X returning Null value – user1603518 Aug 22 '12 at 12:35
  • why don't you add id to your li elements like
  • and find by id? It should work.
  • – some_other_guy Aug 22 '12 at 13:19