(self)
| 299 | assert joined == absolute |
| 300 | |
| 301 | def test_follow_selector(self): |
| 302 | resp = self._links_response() |
| 303 | urls = [ |
| 304 | "http://example.com/sample2.html", |
| 305 | "http://example.com/sample3.html", |
| 306 | "http://example.com/sample3.html", |
| 307 | "http://example.com/sample3.html", |
| 308 | "http://example.com/sample3.html#foo", |
| 309 | "http://www.google.com/something", |
| 310 | "http://example.com/innertag.html", |
| 311 | ] |
| 312 | |
| 313 | # select <a> elements |
| 314 | for sellist in [resp.css("a"), resp.xpath("//a")]: |
| 315 | for sel, url in zip(sellist, urls, strict=False): |
| 316 | self._assert_followed_url(sel, url, response=resp) |
| 317 | |
| 318 | # select <link> elements |
| 319 | self._assert_followed_url( |
| 320 | Selector(text='<link href="foo"></link>').css("link")[0], |
| 321 | "http://example.com/foo", |
| 322 | response=resp, |
| 323 | ) |
| 324 | |
| 325 | # href attributes should work |
| 326 | for sellist in [resp.css("a::attr(href)"), resp.xpath("//a/@href")]: |
| 327 | for sel, url in zip(sellist, urls, strict=False): |
| 328 | self._assert_followed_url(sel, url, response=resp) |
| 329 | |
| 330 | # non-a elements are not supported |
| 331 | with pytest.raises( |
| 332 | ValueError, match="Only <a> and <link> elements are supported" |
| 333 | ): |
| 334 | resp.follow(resp.css("div")[0]) |
| 335 | |
| 336 | def test_follow_selector_list(self): |
| 337 | resp = self._links_response() |
nothing calls this directly
no test coverage detected