I'm trying to click an input button whose main identifiers are dynamically created. Therefore I'm trying to click it based on the span information after it.
<span id="DYNAMIC" class="a-button a-button-primary pmts-button-input apx-compact-continue-action pmts-portal-component pmts-portal-components-DYNAMIC primary-action-button">
<span class="a-button-inner">
<input data-pmts-component-id="DYNAMIC" class="a-button-input a-button-text" type="submit" aria-labelledby="DYNAMIC">
<span id="DYNAMIC" class="a-button-text" aria-hidden="true">
<span>Use this payment method</span>
</span>
</span>
I've put in the word DYNAMIC where the IDs are dynamically created rather than putting in the value. Below is what I think was my best version of the many things I tried but I've still not been able to accomplish the task.
var btnPaymentMethod = driver.FindElement(By.XPath("//input[normalize-space(.//span)='Use this payment method']"));
btnPaymentMethod.Click();