元素不可点击另一个元素获得点击-Selenium C#

时间:2018-08-27 07:39:53

标签: c# unit-testing selenium

我试图单击一个按钮,但是我有一个装载器,需要几秒钟才能消失。这是我收到的错误

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=unknown error: Element <select _ngcontent-c4="" class="col-xs-8 custom-input-styles custom-select ng-untouched ng-pristine ng-invalid" formcontrolname="organizationType">...</select> is not clickable at point (441, 620). Other element would receive the click: <div _ngcontent-c2="" class="loader-wrapper ng-trigger ng-trigger-visibilityChanged ng-animating" style="">...</div>
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.17134 x86_64)
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Click()
   at BnI.UITests.ProceedRedirect.TheProceedRedirectTest() in C:\Users\me\source\repos\WebAPI\src\UITests\UnitTest1.cs:line 60

我尝试了多种解决方案,但仍然收到相同的错误。我尝试过的这种方法

var element = wait.Until(driver => driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='Email Address'])[1]/following::input[1]")));

var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.InvisibilityOfElementLocated(By.XPath("xpath=(.//*[normalize-space(text()) and normalize-space(.)='For support: info@me'])[1]/following::div[1]")));

1 个答案:

答案 0 :(得分:0)

在您点击之前,等待叠加元素消失

在单击所需元素之前,请编写此代码

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[@class='loader-wrapper ng-trigger ng-trigger-visibilityChanged ng-animating']")))