c# 如何使用 selenium webdriver 单击按钮?

c# How to click button using selenium webdriver?

我试图点击 'Sign In' 按钮。 但它根本没有点击。 我的代码在下面。 有人可以帮助我吗?

[FindsBy(How = How.XPath, Using = "//input[@name='ctl00$MainContent$LoginForm$LoginButton' and @value='sign in']")]
    [CacheLookup]
    private IWebElement Submit { get; set; }

    public LoginPage(IWebDriver driver)
    {
        this.driver = driver;
        PageFactory.InitElements(driver, this);
    }

    public void LoginToApplication()
    {
        System.Threading.Thread.Sleep(5000);
        Submit.Click();
     }

尝试下面提到的任何方法 xpath

//button[text()='sign in']

解释:- 使用 text 方法和 <button> 标签。

OR

//button[@class='color'][text()='sign in']

说明:- 使用 class 属性和 text 方法以及 <button> 标签。

OR

//button[@type='button'][text()='sign in']

解释:- 使用 type 属性和 text 方法以及 <button> 标签。

建议:-不用absolute xpath,用relative xpath.