The following is the HTML code for button:
<span>
<button class="buttonLargeAlt" onclick="javascript:submitCheckout(this.form);"type="submit">Checkout</button>
</span>
I tried driver.findElement(By.xpath("//span[contains(.,'Checkout')]")).click();
It is not working...
Any other ideas? There are 2 buttons with same name on the page.
driver.submit()
should work. If the order of the buttons in your DOM is always the same, this should work too:
driver.findElements(By.className("buttonLargeAlt")).get(0).click();
if it is the first buttonLargeAlt button on your page.
Try:
//span/button[text()='Checkout' and @class='buttonLargeAlt']
or
//span/button[text()='Checkout'][1]
Also, if you know which of the 2 buttons you need to click, you can try:
//span/button[text()='Checkout'][1]
Where [1]
is the first button found with a text of 'Checkout'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With