Elixir Hound 等待页面加载
Elixir Hound wait for page to load
我正在提交登录表单,然后尝试使用 elixir / hound 捕获 HTML。提交后我 运行 page_source
什么也没得到。如果我等待一秒钟(让页面完成加载),那么我会返回 html.
有没有办法让猎犬等到页面加载完成?
我目前正在做::timer.sleep(2000)
作为解决方法,希望有更好的方法:/
我就是这样做的:
创建一个函数,每 100 毫秒重复检查一次测试条件,在这种情况下,我正在等待特定文本出现,方法是使用
visible_page_text
@tag timeout: 6000
test "My Test" do
assert wait_for(fn -> Regex.match?(~r/Success/, visible_page_text()) end)
end
def wait_for(func) do
:timer.sleep(100)
case func.() do
true -> true
false -> wait_for(func)
end
end
我正在提交登录表单,然后尝试使用 elixir / hound 捕获 HTML。提交后我 运行 page_source
什么也没得到。如果我等待一秒钟(让页面完成加载),那么我会返回 html.
有没有办法让猎犬等到页面加载完成?
我目前正在做::timer.sleep(2000)
作为解决方法,希望有更好的方法:/
我就是这样做的:
创建一个函数,每 100 毫秒重复检查一次测试条件,在这种情况下,我正在等待特定文本出现,方法是使用 visible_page_text
@tag timeout: 6000
test "My Test" do
assert wait_for(fn -> Regex.match?(~r/Success/, visible_page_text()) end)
end
def wait_for(func) do
:timer.sleep(100)
case func.() do
true -> true
false -> wait_for(func)
end
end