擅长:python、mysql、java
<p>假设您正在使用py.test签入<code>assert</code>,并且希望验证预期异常的消息:</p>
<pre><code>import pytest
def test_foo():
with pytest.raises(Exception) as excinfo:
x = driver.find_element_by_xpath("locator").text
assert excinfo.value.message == 'Unable to locate element'
</code></pre>