本文整理汇总了C#中ILogger.?.ERROR方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.?.ERROR方法的具体用法?C# ILogger.?.ERROR怎么用?C# ILogger.?.ERROR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.?.ERROR方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Navigate
public void Navigate(string url, ILogger log)
{
try
{
log?.INFO($"Start URL navigating: {url}");
_container.Value.Driver.Navigate().GoToUrl(url);
log?.INFO("URL navigating completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during URL {url} navigating");
throw new CommandAbortException($"Error occurred during URL {url} navigating", ex);
}
}
示例2: JSExecutor
public void JSExecutor(string jsScript, ILogger log)
{
try
{
log?.INFO($"Execute javascript");
_container.Value.JavaScriptExecutor.ExecuteScript(jsScript);
log?.INFO("Javascript executing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during javascript execution");
throw new CommandAbortException($"Error occurred during javascript execution:\n{jsScript}", ex);
}
}
示例3: Close
public void Close(ILogger log)
{
try
{
log?.INFO($"Start driver closing");
_container.Value.Driver.Close();
log?.INFO("Driver closing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during driver closing");
throw new CommandAbortException($"Error occurred during driver closing", ex);
}
}
示例4: DismissAlert
public void DismissAlert(ILogger log)
{
try
{
log?.INFO($"Dismiss alert");
IAlert alert = _container.Value.Driver.SwitchTo().Alert();
alert.Dismiss();
log?.INFO("Alert dismissing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during alert dismissing");
throw new CommandAbortException($"Error occurred during alert dismissing", ex);
}
}
示例5: ActionsDragAndDrop
public void ActionsDragAndDrop(WebElement source, WebElement target, ILogger log)
{
var eSource = Find(source, log);
var eTarget = Find(target, log);
try
{
log?.INFO($"Actions drag from {source.Name} to {target.Name}");
new Actions(_container.Value.Driver).MoveToElement(eSource).ClickAndHold(eSource).MoveToElement(eTarget).Release(eTarget).Build().Perform();
log?.INFO("Actions drag and drop completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during actions drag and drop: from {source.Name} to {target.Name}");
throw new CommandAbortException($"Error occurred during actions drag and drop: from {source.Name} to {target.Name}", ex);
}
}
示例6: Find
public IWebElement Find(WebElement element, ILogger log)
{
log?.DEBUG($"Start searching element: {element.Name}");
log?.TRACE($"{element}");
try
{
_sw.Value.Reset();
var el = _container.Value._driver.FindElement(element.Locator.Get());
_sw.Value.Stop();
log?.DEBUG($"Element: {element.Name} has been found. Time: {_sw.Value.ElapsedMilliseconds} ms");
return el;
}
catch (Exception ex)
{
log?.ERROR("Couldn't find element");
throw new CommandAbortException("Couldn't find element", ex);
}
}
示例7: Click
public void Click(WebElement element, ILogger log)
{
var el = Find(element, log);
WaitUntilElementIsVisible(el, log);
WaitUntilElementIsEnabled(el, log);
try
{
log?.INFO($"Click on element: {element.Name}");
el.Click();
log?.INFO("Click completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during clicking on element: {element.Name}");
throw new CommandAbortException($"Error occurred during clicking on element: {element.Name}", ex);
}
}
示例8: ActionsDoubleClick
public void ActionsDoubleClick(WebElement element, ILogger log)
{
var el = Find(element, log);
WaitUntilElementIsVisible(el, log);
WaitUntilElementIsEnabled(el, log);
try
{
log?.INFO($"Actions double click on element: {element.Name}");
new Actions(_container.Value.Driver).DoubleClick(el).Build().Perform();
log?.INFO("Actions double click completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during actions double-clicking on element: {element.Name}");
throw new CommandAbortException($"Error occurred actions during-clicking on element: {element.Name}", ex);
}
}
示例9: WindowMaximize
public void WindowMaximize(ILogger log)
{
try
{
log?.INFO($"Maximize window");
_container.Value.Driver.Manage().Window.Maximize();
log?.INFO("Window maximizing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during window maximizing");
throw new CommandAbortException($"Error occurred during window maximizing", ex);
}
}
示例10: ActionsSendKeys
public void ActionsSendKeys(WebElement element, string value, ILogger log)
{
var el = Find(element, log);
WaitUntilElementIsVisible(el, log);
WaitUntilElementIsEnabled(el, log);
try
{
log?.INFO($"Actions send keys to element: {element.Name}");
new Actions(_container.Value.Driver).SendKeys(el, value).Build().Perform();
log?.INFO("Actions send keys completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during actions keys sending to element: {element.Name}");
throw new CommandAbortException($"Error occurred actions keys sending to element: {element.Name}", ex);
}
}
示例11: SwitchToFrame
public void SwitchToFrame(FrameWebElement elem, ILogger log)
{
try
{
log?.DEBUG($"Switch to frame by locator: {elem}");
var wElem = Find(elem, log);
var frameId = wElem.GetAttribute("id");
_container.Value.Driver.SwitchTo().Frame(frameId);
log?.DEBUG($"Switching to frame completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during switching to frame by locator: {elem}");
throw new CommandAbortException($"Error occurred during switching to frame by locator: {elem}", ex);
}
}
示例12: SetWindowSize
public void SetWindowSize(Size size, ILogger log)
{
try
{
log?.INFO($"Resize window using size: {size.ToString()}");
_container.Value.Driver.Manage().Window.Size = size;
log?.INFO("Window resizing completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during window resizing");
throw new CommandAbortException($"Error occurred during window resizing", ex);
}
}
示例13: ObjectJSExecutor
public object ObjectJSExecutor(string jsScript, ILogger log)
{
try
{
log?.INFO($"Execute javascript: {jsScript}");
return _container.Value.JavaScriptExecutor.ExecuteScript(jsScript);
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during execution: {jsScript}");
throw new CommandAbortException($"Error occurred during javascript execution:\n{jsScript}", ex);
}
}
示例14: Find
public IWebElement Find(WebElement element, ILogger log)
{
log?.DEBUG($"Start searching element: {element.Name}");
log?.TRACE($"{element}");
try
{
_sw.Value.Start();
var isDefaultContent = true;
IWebElement targetElement = null;
var parentStack = new Stack<WebElement>();
for (var currentElement = element.ParentElement; currentElement != null; currentElement = currentElement.ParentElement)
{
parentStack.Push(currentElement);
}
while (parentStack.Count != 0)
{
var workElement = parentStack.Pop();
var frameElement = workElement as FrameWebElement;
if (frameElement != null)
{
SwitchToFrame(frameElement, log);
isDefaultContent = false;
}
}
if (element.Locator.IsRelative)
{
for (var currentElement = element.ParentElement; currentElement != null && !(currentElement.Locator?.IsRelative ?? false); currentElement = currentElement.ParentElement)
{
var frameElement = currentElement as FrameWebElement;
if (frameElement == null)
parentStack.Push(currentElement);
}
if (parentStack.Count != 0)
{
var currentParent = parentStack.Pop();
log?.TRACE($"Start searching parent element: {currentParent.Name}");
log?.TRACE($"{currentParent}");
targetElement = _container.Value.Driver.FindElement(currentParent.Locator.Get());
log?.TRACE($"Parent element: {currentParent.Name} has been found");
while (parentStack.Count != 0)
{
currentParent = parentStack.Pop();
log?.TRACE($"Start searching target parent element: {currentParent.Name}");
log?.TRACE($"{currentParent}");
targetElement = targetElement.FindElement(currentParent.Locator.Get());
log?.TRACE($"Target parent element: {currentParent.Name} has been found");
}
log?.TRACE($"Start searching target element: {currentParent.Name}");
log?.TRACE($"{element}");
targetElement = targetElement.FindElement(element.Locator.Get());
log?.TRACE($"Target element: {element.Name} has been found");
}
else
{
log?.TRACE($"Start searching target parent element: {element.Name}");
log?.TRACE($"{element}");
targetElement = _container.Value.Driver.FindElement(element.Locator.Get());
log?.TRACE($"Target parent element: {element.Name} has been found");
}
}
else
{
log?.TRACE($"Start searching target element: {element.Name}");
log?.TRACE($"{element}");
targetElement = _container.Value.Driver.FindElement(element.Locator.Get());
log?.TRACE($"Target element: {element.Name} has been found");
}
if (!isDefaultContent) SwitchToDefaultContent(log);
_sw.Value.Stop();
log?.INFO("Click completed");
log?.TRACE($"Element: {element.Name} has been found. Time: {_sw.Value.ElapsedMilliseconds} ms");
return targetElement;
}
catch (Exception ex)
{
log?.ERROR("Couldn't find element");
throw new CommandAbortException($"Couldn't find element: {element.Name}", ex);
}
}
示例15: SwitchToFrameById
public void SwitchToFrameById(string id, ILogger log)
{
try
{
log?.DEBUG($"Switch to frame");
_container.Value.Driver.SwitchTo().Frame(id);
log?.DEBUG($"Switching to frame completed");
}
catch (Exception ex)
{
log?.ERROR($"Error occurred during switching to frame");
throw new CommandAbortException($"Error occurred during switching to frame", ex);
}
}