Rocky
Rocky

Reputation: 51

Button isn't clicked (selenium c#)

Just trying below code to click Export button in and it not clicking the button

driver.FindElement(By.XPath("//span[@class='ui-button-text' and contains(.,'Export')]")).Click();

Outer HTML code

Export

<span class="ui-button-text" style="">Export</span>

Upvotes: 2

Views: 69

Answers (2)

Rocky
Rocky

Reputation: 51

Resolved myself after digging into Wait methods. Below code recognizes the button.

new WebDriverWait(driver, TimeSpan.FromSeconds(15)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[@class='ui-button-text' and contains(.,'Export')]"))).Click();

Upvotes: 0

Mate Mrše
Mate Mrše

Reputation: 8394

Use

driver.FindElement(By.XPath("//span[@class='ui-button-text' and contains(.,'Export')]")).click();

(lower-case click()).

Upvotes: 1

Related Questions