我正在尝试自动化 reactjs 应用程序和我们的项目使用的框架,该框架基于 C# 和量角器网络构建。
在任何单击或断言函数后,我收到以下错误,但代码中定义的操作成功执行。
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> OpenQA.Selenium.WebDriverTimeoutException : timeout
这个错误的原因是什么?
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using Protractor;
using System;
using System.Collections.Generic;
public Class personalinformations
{
private NgWebDriver _ngdriver;
public PersonalInformations(IWebDriver driver)
{
_ngdriver = new NgWebDriver(driver);
PageFactory.InitElements(_ngdriver, this);
_ngdriver.IgnoreSynchronization = true;
}
[FindsBy(How = How.Id, Using = "btnSubmit")]
private IWebElement btnsave { get; set; }
public void saveSection()
{
WebDriverWait wait = new WebDriverWait(ngdriver, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*@id='btnSubmit']"));
btnsave.Click();
}
}
注意:虽然使用 Thread.Sleep(1000) 等待有时代码有效。我也尝试使用 Javascript 单击元素,结果是相同的。