title: c# Selenium Select Input based on Span Text
body: <p>I'm trying to select a radio button based on the name of the address.  Below I need to select either the span that has the name or the radio button itself.  Either way looks like it will select the radio button.  I need to do this based on the name within the span class.  There are a random amount of spaces before the name of the person so instead of a StartsWith I've been trying to do this with a contains John Doe. </p>
  
  <pre><code>&lt;div data-a-input-name="selectedAddress" class="a-radio"&gt;
     &lt;label&gt;&lt;input name="selectedAddress" value="113290190603" type="radio"&gt;
      &lt;i class="a-icon a-icon-radio"&gt;&lt;/i&gt;
       &lt;span class="a-label a-radio-label"&gt;
           John Doe, Something RD, Some City, State, #####-####, Phone: #####
       &lt;/span&gt;
     &lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I can't seem to get the correct syntax regardless of all the ways I've tried.  Here are some of the syntax I tried: </p>
  
  <pre><code>var Xpath = "//span[contains(@class,'a-label a-radio-label')][contains(text(),'" + shipName + "')]]";
  
              var radio = driver.FindElement(By.XPath(Xpath));
              radio.Click();
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>var Xpath = ".//input[following-sibling::strong[contains(.,'" + shipName + "')]]";
              var radio = driver.FindElement(By.XPath(Xpath));
              radio.Click();
  </code></pre>
  
  <p>I cannot point to a specific point with XPath because the item I am looking for might not necessarily be in the same ordered location.  That is why I need to search for it by name. I also cannot do it by the value of the input as I do not know that information beforehand.  I've actually tried many other variances of the two XPATH syntaxes shown above, but those are what I have left now as examples.  Thanks for your help. </p>