1

如何从Selenium::Remote::Driver捕获错误。我知道它显示了远程驱动程序响应,但是对于如何实现这一点有点令人困惑。我目前在我的命令周围使用 eval 但有更好的方法来捕获特定错误吗?

[我对 perl 的 selenium 有点陌生]

4

1 回答 1

2

No, that's already how one works with that module. It throws exceptions for every little thing that can go wrong (a design mistake in my book), so you have no other choice but to catch them. Perhaps switch to Try::Tiny if you want syntactic sugar.

Since the module errors are untyped strings (another design mistake), you cannot catch specific errors. You have to catch all and parse them.

于 2013-08-29T12:54:09.657 回答