Skip to content

Commit

Permalink
Merge pull request #47 from adeel41/master
Browse files Browse the repository at this point in the history
Ignore whitespace when using XenonElementsFinder TextIs method
  • Loading branch information
adeel41 committed Sep 16, 2015
2 parents 180a566 + 46f02b0 commit e4003d6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,4 @@ Xenon.sln.ide/
/packages
packages/
*.ncrunchsolution
.vs/config/applicationhost.config
5 changes: 4 additions & 1 deletion Xenon.Tests/EmbeddedResourceLookup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Reflection;
using System.Text;

Expand Down Expand Up @@ -28,6 +29,8 @@ public string GetContent( string htmlFileName )
{
string resourceIdentifier = GetFullPath( htmlFileName );
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( resourceIdentifier );
if ( stream == null )
throw new ArgumentNullException( htmlFileName, "Unable to find following resource in the assembly: " + resourceIdentifier );
var content = new StreamReader( stream ).ReadToEnd();
return content;
}
Expand Down
15 changes: 10 additions & 5 deletions Xenon.Tests/Integration/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ public void Configuration( IAppBuilder app )
formAsync.Wait();
PostbackResult = new NameValueCollection();
var postbackResult = new NameValueCollection();
foreach ( var val in formAsync.Result )
{
PostbackResult.Add( val.Key, String.Join(",",val.Value) );
postbackResult.Add( val.Key, String.Join(",",val.Value) );
}
}
PostbackResult = postbackResult;
}
return Task.Delay( 0 );
} );
Expand All @@ -64,8 +65,12 @@ public static NameValueCollection GetPostResult()
var startTime = DateTime.Now;
while ( startTime.AddMinutes( 2 ) > DateTime.Now )
{
if ( PostbackResult != null )
return PostbackResult;
if ( PostbackResult != null )
{
var postbackResult = PostbackResult;
PostbackResult = null;
return postbackResult;
}
}
return null;
}
Expand Down
1 change: 1 addition & 0 deletions Xenon.Tests/Xenon.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<Link>chromedriver.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="XenonElementsFinderTests\Issue46_IgnoreWhiteSpace.html" />
<EmbeddedResource Include="AssertTests\PageWithInputs.html" />
<EmbeddedResource Include="InputTests\InputTests.html" />
</ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions Xenon.Tests/XenonElementsFinderTests/Issue46_IgnoreWhiteSpace.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<a href="http://www.google.co.uk">
Hello World
</a>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public void AttributeIs_WhenMultipleAttributeIsAndTextIsMethodsAreUsed_ShouldFin
.Assert( a => a.ContainsElement( where => @where.TextIs( "Three" ) ) ) );
}

[Test]
public void TextIs_WhenContainsWhiteSpace_ShouldFindTheElement_Issue46()
{
StartTest( "Issue46_IgnoreWhiteSpace", xt =>
xt.Assert( a => a.ContainsElement( where => where.TextIs( "Hello World" ) ) ) );
}

[Test]
public void CriteriaDetails_WithAttributeIsCriteria_DisplaysAttributeCriteriaText()
{
Expand All @@ -72,7 +79,7 @@ public void CriteriaDetails_WithTextIsCriteria_DisplaysTextIsCriteriaText()
{
var finder = new XenonElementsFinder( null );
finder.TextIs( "Hello World" );
Assert.AreEqual( "(//input[@value='Hello World' and (@type='submit' or @type='button' or @type= 'reset' ) ] | //*[text() = 'Hello World'])", finder.CriteriaDetails() );
Assert.AreEqual( "(//input[@value='Hello World' and (@type='submit' or @type='button' or @type= 'reset' ) ] | //*[normalize-space(text()) = normalize-space('Hello World')])", finder.CriteriaDetails() );
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions Xenon.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd" >
<metadata>
<id>Xenon</id>
<version>0.1.7</version>
<version>0.1.8</version>
<title>Xenon</title>
<authors>Liquid Thinking</authors>
<projectUrl>https://github.com/LiquidThinking/Xenon</projectUrl>
Expand All @@ -14,7 +14,7 @@
There are the following pre-built browser automation wrappers:
http://www.nuget.org/packages/Xenon.Selenium/
</description>
<releaseNotes>Minor Change: Added Try Catch Block in WaitUntil</releaseNotes>
<releaseNotes>Minor Change: ignore whitespace when comparing using XenonElementsFinder </releaseNotes>
<dependencies>
</dependencies>
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions Xenon/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.7.0")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: AssemblyVersion( "0.1.8.0" )]
[assembly: AssemblyFileVersion( "0.1.8.0" )]
[assembly: InternalsVisibleTo("Xenon.Selenium")]
2 changes: 1 addition & 1 deletion Xenon/XenonElementsFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public virtual string CreateCriteriaForcingSearchAll()

private class FindByTextXpathCriteria : BaseXpathCriteria
{
private const string Format = "(//input[@value='{0}' and (@type='submit' or @type='button' or @type= 'reset' ) ] | //*[text() = '{0}'])";
private const string Format = "(//input[@value='{0}' and (@type='submit' or @type='button' or @type= 'reset' ) ] | //*[normalize-space(text()) = normalize-space('{0}')])";

public FindByTextXpathCriteria( string text ) : base( Format, text ) {}

Expand Down

0 comments on commit e4003d6

Please sign in to comment.