internal/testing/htmlcheck: remove InAt

The same can be achieved with CSS selectors, using :nth-child
and :nth-of-type.

Change-Id: I57486922d5d0060862b20d67f56be808b6c65082
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/617945
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/frontend/header_test.go b/internal/frontend/header_test.go
index c140e07..af775bd 100644
--- a/internal/frontend/header_test.go
+++ b/internal/frontend/header_test.go
@@ -158,7 +158,6 @@
 func TestBreadcrumbPath(t *testing.T) {
 	var (
 		in    = htmlcheck.In
-		inAt  = htmlcheck.InAt
 		notIn = htmlcheck.NotIn
 		text  = htmlcheck.HasText
 		attr  = htmlcheck.HasAttr
@@ -171,8 +170,8 @@
 		{
 			"example.com/blob/s3blob", "example.com", internal.LatestVersion,
 			in("",
-				inAt("a", 0, href("/example.com"), text("example.com")),
-				inAt("a", 1, href("/example.com/blob"), text("blob")),
+				in("a:nth-of-type(1)", href("/example.com"), text("example.com")),
+				in("a:nth-of-type(2)", href("/example.com/blob"), text("blob")),
 				in("span.DetailsHeader-breadcrumbCurrent", text("s3blob"))),
 		},
 		{
@@ -185,8 +184,8 @@
 		{
 			"g/x/tools/go/a", "g/x/tools", internal.LatestVersion,
 			in("",
-				inAt("a", 0, href("/g/x/tools"), text("g/x/tools")),
-				inAt("a", 1, href("/g/x/tools/go"), text("go")),
+				in("a:nth-of-type(1)", href("/g/x/tools"), text("g/x/tools")),
+				in("a:nth-of-type(2)", href("/g/x/tools/go"), text("go")),
 				in("span.DetailsHeader-breadcrumbCurrent", text("a"))),
 		},
 		{
@@ -205,8 +204,8 @@
 		{
 			"example.com/blob/s3blob", "example.com", "v1",
 			in("",
-				inAt("a", 0, href("/example.com@v1"), text("example.com")),
-				inAt("a", 1, href("/example.com/blob@v1"), text("blob")),
+				in("a:nth-of-type(1)", href("/example.com@v1"), text("example.com")),
+				in("a:nth-of-type(2)", href("/example.com/blob@v1"), text("blob")),
 				in("span.DetailsHeader-breadcrumbCurrent", text("s3blob"))),
 		},
 	} {
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index 61204b9..22c694c 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -189,7 +189,6 @@
 
 	var (
 		in   = htmlcheck.In
-		inAt = htmlcheck.InAt
 		text = htmlcheck.HasText
 		attr = htmlcheck.HasAttr
 
@@ -509,8 +508,8 @@
 				in("li.selected", text(`Imports`)),
 				in(".Imports-heading", text(`Standard Library Imports`)),
 				in(".Imports-list",
-					inAt("a", 0, href("/fmt"), text("fmt")),
-					inAt("a", 1, href("/path/to/bar"), text("path/to/bar")))),
+					in("li:nth-child(1) a", href("/fmt"), text("fmt")),
+					in("li:nth-child(2) a", href("/path/to/bar"), text("path/to/bar")))),
 		},
 		{
 			name:           "package@version imported by tab",
diff --git a/internal/testing/htmlcheck/htmlcheck.go b/internal/testing/htmlcheck/htmlcheck.go
index d6cc766..de49b84 100644
--- a/internal/testing/htmlcheck/htmlcheck.go
+++ b/internal/testing/htmlcheck/htmlcheck.go
@@ -60,26 +60,6 @@
 	}
 }
 
-// InAt is like In, but instead of the first node satifying the selector, it
-// applies the Checkers to the i'th node.
-// InAt(s, 0, m) is equivalent to (but slower than) In(s, m).
-func InAt(selector string, i int, checkers ...Checker) Checker {
-	sel := mustParseSelector(selector)
-	if i < 0 {
-		panic("negative index")
-	}
-	return func(n *html.Node) error {
-		els := allMatching(n, sel)
-		if i >= len(els) {
-			return fmt.Errorf("%q: index %d is out of range for %d elements", selector, i, len(els))
-		}
-		if err := check(els[i], checkers); err != nil {
-			return fmt.Errorf("%s[%d]: %v", selector, i, err)
-		}
-		return nil
-	}
-}
-
 // InAll runs the checkers against all nodes matching selector.
 func InAll(selector string, checkers ...Checker) Checker {
 	sel := mustParseSelector(selector)
diff --git a/internal/testing/pagecheck/pagecheck.go b/internal/testing/pagecheck/pagecheck.go
index f53407d..216c133 100644
--- a/internal/testing/pagecheck/pagecheck.go
+++ b/internal/testing/pagecheck/pagecheck.go
@@ -42,7 +42,6 @@
 
 var (
 	in        = htmlcheck.In
-	inAt      = htmlcheck.InAt
 	inAll     = htmlcheck.InAll
 	text      = htmlcheck.HasText
 	exactText = htmlcheck.HasExactText
@@ -106,8 +105,8 @@
 		link = in("table.Directories a", href(firstHref), exactText(firstText))
 	}
 	return in("",
-		inAt("th", 0, text("^Path$")),
-		inAt("th", 1, text("^Synopsis$")),
+		in("th:nth-child(1)", text("^Path$")),
+		in("th:nth-child(2)", text("^Synopsis$")),
 		link)
 }
 
@@ -130,7 +129,7 @@
 func OverviewDetails(ov *Overview) htmlcheck.Checker {
 	var pkg htmlcheck.Checker
 	if ov.PackageURL != "" {
-		pkg = inAt(".Overview-sourceCodeLink a", 1,
+		pkg = in(".Overview-sourceCodeLink a:nth-of-type(2)",
 			href(ov.PackageURL),
 			exactText(ov.PackageURL))
 	}
@@ -138,7 +137,7 @@
 		in("div.Overview-module > a",
 			href(ov.ModuleLink),
 			exactText(ov.ModuleLinkText)),
-		inAt(".Overview-sourceCodeLink a", 0,
+		in(".Overview-sourceCodeLink a:nth-of-type(1)",
 			href(ov.RepoURL),
 			exactText(ov.RepoURL)),
 		pkg,