LoginSignup
1
2

More than 5 years have passed since last update.

href がない a タグを XPath で取得する

Posted at

Capybara 使ってテストしようとしたのだけど、やり方がわからなかったので調べた。
時間かかったけどやり方見つけたので備忘録。

have_xpath(%(//a[contains(normalize-space(string()), "ほげ 1") and not(@href)]))

normalize-space の存在を知るのに時間がかかった。
Capybara のソースに XPath.string.n.is(locator) というのを見つけてようやくわかった。

XPath は滅多に使わんので使う度に色々と忘れてますな。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2