使用黄瓜站点棱镜。我正在导航到一个页面并想要检查该页面上存在的所有元素。我使用了此代码,但无法打印此通用消息。
“@sign_in”是我定义了所有登录元素的类的对象“表”包含所有元素名称
table.hashes.each do |link|
expect(@sign_in.send(link[:Login_elements])).to be_truthy , "link[:Login_elements]) is not present"
end
使用黄瓜站点棱镜。我正在导航到一个页面并想要检查该页面上存在的所有元素。我使用了此代码,但无法打印此通用消息。
“@sign_in”是我定义了所有登录元素的类的对象“表”包含所有元素名称
table.hashes.each do |link|
expect(@sign_in.send(link[:Login_elements])).to be_truthy , "link[:Login_elements]) is not present"
end
您通过调用的方法send
返回元素,或者如果该元素不在无法与 be_truthy 一起使用的页面上,则引发异常。相反,您需要使用布尔 has_xxx? site-prism 提供的方法(或者您可以将 raise_error 匹配器与代码块一起使用)
table.hashes.each do |link|
expect(@sign_in.send("has_#{link[:Login_elements]}?")).to be_truthy , "link[:Login_elements]) is not present"
end