c# - 无法点击登录按钮
问题描述
<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">
</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>
请帮我解决这个问题。
解决方案
点击注册按钮 InduceWebDriverWait
并等待ElementToBeClickable
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("register-btn"))).Click();
如果你仍然有同样的问题,那么你需要诱导Javascript
Executor 点击。
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].click();", driver.FindElement(By.Id("register-btn")));
推荐阅读
- java - 如何在 Thymeleaf 中使用对象中包含的 HashMap 填充下拉列表?
- java - VSC 中的“问题”没有找到基本的打字错误
- javascript - 如何处理 Selenium2 中的模式引导弹出窗口
- python - 在 Celery 任务期间保存对象
- express - axios 发布到 nodejs 服务器但 nodejs 无法获取数据
- java - 添加前删除 Arraylist 数据
- javascript - 如何在 Vue.js 的插槽内使用模板标签?
- django - 带有 Google 新闻语法的 Django 站点地图
- python - 获取绘图 matplotlib 的 x 和 y 刻度
- html - 在 Angular 项目中注册服务人员时出错