Skip to content

Commit

Permalink
#211 NoSuchElementException is thrown when access UIComponent.IsVisib…
Browse files Browse the repository at this point in the history
…le property of hidden/missing element; Add UIComponent_IsVisible test
  • Loading branch information
YevgeniyShunevych committed Oct 7, 2018
1 parent 27ab64e commit 9ba5150
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Atata.Tests/Components/ContentPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class ContentPage : Page<_>
[FindSettings(Visibility = Visibility.Any)]
public Content<string, _> HiddenDiv { get; private set; }

[FindById("hidden-div")]
public Content<string, _> HiddenDivWithVisibleVisibility { get; private set; }

[FindById("hidden-div", Visibility = Visibility.Hidden)]
[ContentSource(ContentSource.TextContent)]
public Content<string, _> HiddenDivUsingTextContent { get; private set; }
Expand Down
36 changes: 35 additions & 1 deletion src/Atata.Tests/UIComponentTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using FluentAssertions;
using NUnit.Framework;
using OpenQA.Selenium;

namespace Atata.Tests
Expand Down Expand Up @@ -46,6 +47,39 @@ public void UIComponent_Content_Invisible()
HiddenDivUsingInnerHtml.Content.Should.Equal("Some <b>text</b>");
}

[Test]
public void UIComponent_IsVisible()
{
var page = Go.To<ContentPage>();

using (StopwatchAsserter.Within(0))
page.VisibleDiv.IsVisible.Value.Should().BeTrue();

using (StopwatchAsserter.Within(0))
page.VisibleDiv.IsVisible.Should.BeTrue();

using (StopwatchAsserter.Within(0))
page.VisibleDiv.Should.BeVisible();

using (StopwatchAsserter.Within(0))
page.HiddenDiv.IsVisible.Value.Should().BeFalse();

using (StopwatchAsserter.Within(0))
page.HiddenDiv.IsVisible.Should.BeFalse();

using (StopwatchAsserter.Within(0))
page.HiddenDiv.Should.BeHidden();

using (StopwatchAsserter.Within(0))
page.HiddenDivWithVisibleVisibility.IsVisible.Value.Should().BeFalse();

using (StopwatchAsserter.Within(0))
page.HiddenDivWithVisibleVisibility.IsVisible.Should.BeFalse();

using (StopwatchAsserter.Within(0))
page.HiddenDivWithVisibleVisibility.Should.BeHidden();
}

[Test]
public void UIComponent_Wait_Until_Visible()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Atata/Components/UIComponent`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ internal sealed override bool OnMissing(SearchOptions options)

protected virtual bool GetIsVisible()
{
return Scope.Displayed;
return GetScope(SearchOptions.SafelyAtOnce())?.Displayed ?? false;
}

protected virtual string GetContent()
Expand Down

0 comments on commit 9ba5150

Please sign in to comment.