I'm trying to select a button that is dynamically created based on the name of the person in the span and I am having trouble getting the XPATH syntax correct. There would be several of these buttons dynamically created on the page so the identifier I need to use is the customer name. Here is the HTML of the button.
<button id="172369678903-announce" name="172369678903" data-selected-address-id="172369678903" data-unit-ids="["miq://document:1.0/Contract/a:1.0/Unit:1.0/dc290763-6cce-46c5-a878-3b5b0e615740#35176ee2-51c5-479b-b63e-a2cc958a2de9"]" data-url="/spr/returns/addressSelection/dc290763-6cce-46c5-a878-3b5b0e615740" class="a-button-text selected-address" type="button">
<div class="a-column a-span12">
<div class="a-row">
<div class="a-section a-spacing-none a-text-left">
<span class="a-text-bold">
John Doe
</span>
</div>
</div>
<div class="a-row">
<div class="a-section a-spacing-none a-text-left">
<span>
20410 SOME STREET, WALNUT, CA, 91789-2435
</span>
</div>
</div>
<div class="a-row">
<div class="a-section a-spacing-none a-text-left">
<span>
Phone number: 2813308004
</span>
</div>
</div>
</div>
</button>
I have the information John Doe and that is how I need to be able to click on this item. Here is the XPATH syntax I currently have but have tried many different forms of it. The variable shipName contains the name John Doe in it.
var addyFinder = driver.FindElement(By.XPath("//button/span[contains(text(),'" + shipName.Trim() + "')]"));