首页 > 解决方案 > 仅在一台 PC 中因单击拦截而导致测试失败

问题描述

我指的测试在我的 PC 上是可以的,但是当我的同事尝试运行它时,她收到以下消息:

Test method EVO4.Apresentacao.Angular.Teste.Brasil.Modulos.Geral.Menus.AdministrativoContratos threw exception:
    OpenQA.Selenium.ElementClickInterceptedException: element click intercepted: Element <a href="#tabs-log" id="btnLog" class="ui-tabs-anchor" role="presentation" tabindex="-1">...</a> is not clickable at point (342, 113). Other element would receive the click: <div style="position: relative;" class="row-fluid">...</div>
      (Session info: chrome=88.0.4324.104)

代码行是:

Driver.FindElement(By.Id("btnLog")).Click();

该按钮的 HTML 是:

<li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tabs-log" aria-labelledby="btnLog" aria-selected="false"><a href="#tabs-log" id="btnLog" class="ui-tabs-anchor" role="presentation" tabindex="-1">Histórico</a>
      <a href="#tabs-log" id="btnLog" class="ui-tabs-anchor" role="presentation" tabindex="-1">Histórico</a>
</li>

当它应该被点击时,元素在她的屏幕上可见,但它与我的屏幕处于不同的位置,因为 selenium 正在按 Id 搜索,这对我来说没有任何意义。

为什么这不会发生在我身上,我该如何解决这个问题?

标签: c#selenium-webdriverautomated-tests

解决方案


推荐阅读