首页 > 解决方案 > 无法点击登录按钮

问题描述

<div class="form-group dl-padding-10">

                        <select class="form-control form-control-solid" name="SelectedRoleID" id="SelectedRoleID" onchange="removeBorderColor()" required="">
                              
                        </select>
                        <div class="dl-align-left" id="show_text" style="color:red">
                            &nbsp;
                        </div>

                    </div>

                    <div class="circle1-mask form-group" id="FingerprintContent" style="height:140px;z-index:2; background-image: none;">
                        <img src="Assets/img/fingerprint4.gif" id="fingerprint-img" data-status="active" style="height:140px; width:100px;" onclick="DeviceScript.scanFingerPrint(event)">
                    </div>
                        <div class="form-group dl-padding-10">
                            <button type="submit" id="register-btn" class="btn btn-block dl-button-primary dl-no-margin">Sign In (For Testing Purpose Only)</button>
                        </div>


                </div>
            </div>
</form>    </div>
</div>





<button type="submit" id="register-btn" class="btn btn-block dl-button-primary dl-no-margin">Sign In (For Testing Purpose Only)</button>

您可以在上面找到包含大部分信息的 HTML 代码。

按钮的 HTML 出现在上述代码的最后一行。

我的编码:[code][2]

我得到的错误:

OpenQA.Selenium.ElementClickInterceptedException : element click intercepted: Element <button type="submit" id="register-btn" class="btn btn-block dl-button-primary dl-no-margin">...</button> is not clickable at point (758, 646). Other element would receive the click: <div class="footer navbar-fixed-bottom">...</div>

请帮我解决这个问题。

标签: c#seleniumunit-testingxpathautomated-tests

解决方案


点击注册按钮 InduceWebDriverWait并等待ElementToBeClickable

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
 wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("register-btn"))).Click();

如果你仍然有同样的问题,那么你需要诱导JavascriptExecutor 点击。

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].click();", driver.FindElement(By.Id("register-btn")));

推荐阅读