nimaomao
nimaomao

Reputation: 61

How to click this button using Selenium C#?

 <div class="mdl-align"> == $0
    : :before
    <button class="fp-upload-btn btn-primary btn">Upload this file</button> == $0
    : :after
 </div>

The above codes are from a website, however I am unable to click this button despite trying multiple attempts. Im using selenium with C# to do an automation testing. What this button does, is to simply submit a form.

Upvotes: 2

Views: 11725

Answers (1)

Jainish Kapadia
Jainish Kapadia

Reputation: 2611

Try to use xpath locator to click on Upload this file button.

driver.FindElement(By.XPath("//button[contains(text(), 'Upload this file')]")).Click();

Upvotes: 6

Related Questions