Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

work around for bug in ChromeDriver's ability to get Links By.LinkText

  • Loading branch information...
commit 0f9a6e25085a6e98725c86dc2e24f922dacd6295 1 parent 3ca5738
@handcraftsman handcraftsman authored
View
8 src/FluentWebUITesting/Extensions/BrowserExtensions.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using System.Web;
using FluentWebUITesting.Accessors;
using FluentWebUITesting.Controls;
@@ -164,8 +165,13 @@ public static LinkWrapper LinkWithId(this IWebDriver browser, [NotNull] string i
public static LinkWrapper LinkWithVisibleText(this IWebDriver browser, [NotNull] string text)
{
+ var htmlEscapedText = HttpUtility.HtmlEncode(text);
const string howFound = "link with visible text '{0}'";
- var link = browser.FindElements(By.LinkText(text)).FirstOrDefault();
+ var link = browser.FindElements(By.LinkText(text)).FirstOrDefault() ?? browser.GetElementsByTagType("a").FirstOrDefault(x =>
+ {
+ var attribute = x.GetAttribute("innerHTML");
+ return attribute == htmlEscapedText;
+ });
return new LinkWrapper(link, String.Format(howFound, text), browser);
}
View
1  src/FluentWebUITesting/FluentWebUITesting.csproj
@@ -63,6 +63,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
+ <Reference Include="System.Web" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
Please sign in to comment.
Something went wrong with that request. Please try again.