user9790882
user9790882

Reputation: 57

what locator can i use for span element with button tagname

What locator can i use for the below:

<button class="buttonLeftEnabled  floatLeft" type="submit"><span>Continue</span></button>

Upvotes: 0

Views: 663

Answers (2)

Kaustubh
Kaustubh

Reputation: 506

To locate the Continue button, you can use:

driver.findElement(By.xpath("//button[@type='submit']").click();

OR

driver.findElement(By.xpath("//button[@contains(text(),'Continue')]").click();

Hope this helps.

Upvotes: 3

undetected Selenium
undetected Selenium

Reputation: 193088

To locate the button with text as Continue you can use either of the following solutions:

  • cssSelector:

    WebElement elem = driver.findElement(By.cssSelector("button.buttonLeftEnabled.floatLeft>span")).click();
    
  • xpath:

    WebElement elem = driver.findElement(By.xpath("//button[@class='buttonLeftEnabled  floatLeft']/span[contains(.,'Continue')]")).click();
    

Upvotes: 0

Related Questions