Selenium WebDriver Click() fails with IE9

前端 未结 10 1874
礼貌的吻别
礼貌的吻别 2021-02-15 17:13

(I\'ve looked at many other similar posts on SO and have unfortunately not been able to solve this problem, so here goes...)

I\'m using Selenium WebDriver (C# implementa

10条回答
  •  闹比i
    闹比i (楼主)
    2021-02-15 18:10

    The following worked for me:

    @FindBy(id = "submit_action")
    WebElement submitButton_;
    ...
    public void clickSubmit() {
    
        if (driver_ instanceof InternetExplorerDriver) {
            ((JavascriptExecutor) driver_).executeScript("arguments[0].fireEvent('onclick');", submitButton_);
        }
        else {
            submitButton_.click();
        }
    }
    

    As fireEvent is only supported by IE hence the alternative.

提交回复
热议问题