Skip to content

Instantly share code, notes, and snippets.

@jimevans
Last active October 31, 2016 21:27
Show Gist options
  • Save jimevans/a824a17162c3c75a7e76d0c0c2ea0cd4 to your computer and use it in GitHub Desktop.
Save jimevans/a824a17162c3c75a7e76d0c0c2ea0cd4 to your computer and use it in GitHub Desktop.
namespace Tests
{
[TestClass]
public class uhtest : TestBase
{
[TestMethod]
public void TestMethod1()
{
Pages.SiteMap.GoTo();
var allTextBoxes = Browser.Driver.FindElements(By.XPath("//a[starts-with(@href, '/c/Carts')]"));
foreach (var textBox in allTextBoxes)
{
string targetUrl = textBox.GetAttribute("href");
if (string.IsNullOrEmpty(targetUrl))
{
Console.WriteLine("Found an empty href");
}
Uri fullUri = new Uri(targetUrl);
HttpWebRequest request = HttpWebRequest.Create(fullUri) as HttpWebRequest;
request.Method = "GET";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Console.WriteLine("Navigating to target {0} yielded status code {1}", targetUrl, response.StatusCode);
}
Console.WriteLine("poop");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment