Check Alert Message with Poltergeist or Capybara Webkit

Use accept_alert to get the alert message.

That means you can same syntax for Poltergeist or capybara-webkit.

expect(accept_alert).to eq("Javascript alert message")

# or with block syntax

# will fail if alert message doesn't match
accept_alert("Javascript alert message") do 
  # next expectation
end

The first one expect(accept_alert).to reads a bit weird, but that’s the return value of accept_alert.

Archived discussion

Comments from the old blog, preserved as originally posted.

Qihuan Piao

Qihuan Piao

Originally from China and now living in Tokyo, I started this blog to practice English. Over the years, writing helped me find my own voice and explore thoughts about identity, life, and ordinary things that catch my curiosity. I mostly write for myself, but I love it when something here connects with someone else.

Meanwhile, what I wrote in Japanese

何の論点も結論もない7月1日に描いた文字

July 2, 2016

Meanwhile, what I wrote in Chinese

被抬高的感觉,真差

June 30, 2016