dimanche 12 août 2018

Get Checkbox label text Selenium C#

I'm trying to get the text value of checkbox label. Here is an HTML code

<div id="content" class="large-12 columns">
        <div class="example">
  <h3>Checkboxes</h3>
  <form id='checkboxes'>
    <input type="checkbox"> checkbox 1</br>
    <input type="checkbox" checked> checkbox 2
  </form>
</div>

So What I have tried so far

  1. Driver.FindElement(By.XPath("//input[@type='checkbox']")).Text;
  2. Driver.FindElement(By.XPath("//input[@type='checkbox']")).GetAttribute("value");
  3. Driver.FindElement(By.XPath("//input[@type='checkbox']")).GetAttribute("name");
  4. Driver.FindElement(By.XPath("//input[@type='checkbox']")).GetAttribute("innerText");
  5. Driver.FindElement(By.XPath("//input[@type='checkbox']")).GetAttribute("innerHTML");

All this attempts return "". Any ideas how to get it or Javascript is my only option ?




Aucun commentaire:

Enregistrer un commentaire