Question: ```
<button class="sfc-value sfc-js-change sfc-js-field sfc-ui-btn fo-ui-btn fo-ui-container fo-ui-fixed style-114 layout-156 sfc-js-click" type="button">
    <span class="sfc-caption fo-ui-label style-115 layout-157 fo-ui-no-icon">Next</span>
</button>

```

I am new to selenium and I am confused with the classes to target in here. So any best way to target the element .I need to click the button here.

Answer: 
You create an xpath that starts with the span using the text contained, then refer -back- to the button itself:

```
driver.findElement(By.xpath("//span[text()='Next']/..")).click();

```

\*\*edited
To desired element is a dynamic element so to target the element and click it you have to induce *WebDriverWait* for the desired *element to be clickable* and you can use either of the following (**Java**) solutions:

* *cssSelector*:

```
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.sfc-value.sfc-js-change.sfc-js-field.sfc-ui-btn.fo-ui-btn.fo-ui-container.fo-ui-fixed.style-114.layout-156.sfc-js-click>span.sfc-caption.fo-ui-label.style-115.layout-157.fo-ui-no-icon"))).click();

```
* *xpath*:

```
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='sfc-value sfc-js-change sfc-js-field sfc-ui-btn fo-ui-btn fo-ui-container fo-ui-fixed style-114 layout-156 sfc-js-click']/span[contains(text(),'Next')]"))).click();

```