У меня есть следующая проблема в моем приложении, но я приведу вам пример с использованием страницы StackOverflow, так как я получу ту же проблему. Страница, ожидая отображения элемента, и попытаться нажать на логотип. Но я получаю следующее сообщение об ошибке: < /p>
Код: Выделить всё
Message:
OpenQA.Selenium.JavaScriptException : javascript error: window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details
JavaScript stack:
Error: window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details
at eval (eval at (:457:26), :79:11)
at eval (eval at (:457:26), :91:4)
at :457:47
at new Promise ()
at executeAsyncScript (:451:17)
at :481:29
at callFunction (:386:22)
at :400:23
at :401:3
(Session info: chrome=134.0.6998.36)
Stack Trace:
WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
WebDriver.ExecuteAsync(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
WebDriver.ExecuteAsyncScript(String script, Object[] args)
NgWebDriver.ExecuteAsyncScript(String script, Object[] args)
NgWebDriver.WaitForAngular()
NgWebDriver.FindElement(By by)
ISearchContext.FindElement(By by)
DefaultElementLocator.LocateElement(IEnumerable`1 bys)
WebElementProxy.get_WrappedElement()
WebElementProxy.get_Displayed()
c__DisplayClass0_0.b__0(IWebDriver driver) line 10
DefaultWait`1.Until[TResult](Func`2 condition, CancellationToken token)
DefaultWait`1.Until[TResult](Func`2 condition)
BaseComponent.WaitForElementToBeDisplayed() line 227
LogInLogOutValidation.Test() line 40
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
< /code>
Тест выглядит так: < /p>
[Fact]
public void Test()
{
DriverFactory.CurrentDriver.SetUrl("https://stackoverflow.com/questions/72938900/getting-this-error-org-openqa-selenium-javascriptexception-javascript-error-a");
_stackOverflow.ButtonLogo.WaitForElementToBeDisplayed();
_stackOverflow.ButtonLogo.Click();
var title = _stackOverflow.LabelMainBar.GetText();
Assert.Equal("Newest Questions", title);
}
< /code>
selecter buttonlogo: < /p>
[FindsBy(How = How.XPath, Using = "//*[@id='s-topbar--logo']")]
private IWebElement _buttonLogo;
public void WaitForElementToBeDisplayed()
{
GetFluentWait().Until(CustomExpectedConditions.ElementToBeDisplayed(_baseWebElement));
}
protected DefaultWait GetFluentWait()
{
WebDriverWait wait = new WebDriverWait(DriverFactory.CurrentDriver, TimeSpan.FromSeconds(10))
{
PollingInterval = TimeSpan.FromSeconds(1)
};
wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException), typeof(StaleElementReferenceException));
return wait;
}
< /code>
Что я наблюдал, так это то, что даже если я делаю повторение после каждых 1 секунды в течение максимума 10 секунд, тест быстро проходит через этот флюентвейт, и я не могу понять, почему. < /p>
У меня такая же проблема в режиме отладки, даже если я жду, чтобы увидеть элемент на странице. Есть та же проблема.
Кто -нибудь знает, как ждать пуговица, чтобы я мог нажать на это?>
Подробнее здесь: https://stackoverflow.com/questions/795 ... ts-to-be-d