Видео:
Gojko Adzic: Win big with Specification by Example from Dmitry Zhariy on Vimeo.
Author/Presenter: Gojko Adzic
Презентация:
Gojko Adzic: Win big with Specification by Example from Dmitry Zhariy on Vimeo.
Author/Presenter: Gojko Adzic
Specification by Example from Dmitry Zhariy on Vimeo.
Challenging requirements - Gojko Adzic from devtraining.ee on Vimeo.
public static string GetElementVisibility(Element element) { string visibilityProp = element.Style.GetAttributeValue("visibility"); if (element.Style.GetAttributeValue("visibility").Equals("inherit", StringComparison.OrdinalIgnoreCase)) { return GetElementVisibility(element.Parent); } else { return visibilityProp; } } public static bool ExistsAndVisible(this Element element) { bool elementExists = element.Exists; if (elementExists) { bool hasStyleDisplayNone = element.Style.Display.Equals("none", StringComparison.OrdinalIgnoreCase); string visibilityProp = GetElementVisibility(element); bool hasStyleVisibilityHidden = visibilityProp.Equals("hidden", StringComparison.OrdinalIgnoreCase); elementExists = !hasStyleDisplayNone && !hasStyleVisibilityHidden; } return elementExists; }
public static bool IsVisible<TElement>(this TElement element, bool assert = false, bool assertExpectedValue = true) where TElement : Element { var result = element.Style.Display.ToLower() != "none"; if (result && Settings.MaxVisibilitySearchScope > 0) { var parent = element.Parent; for (var i = 0; i < Settings.MaxVisibilitySearchScope; i++) { if (!result || parent == null) { break; } result = parent.Style.Display.ToLower() != "none"; parent = parent.Parent; } } if (assert) { #if !Xunit Assert.AreEqual(assertExpectedValue, result, string.Format("Element of type '{0}' is {1}visible", typeof(TElement).Name, assertExpectedValue ? "not " : string.Empty)); #else Assert.True(assertExpectedValue == result, string.Format("Element of type '{0}' is {1}visible", typeof(TElement).Name, assertExpectedValue ? "not " : string.Empty)); #endif } return result; }