Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phantomjs 使用wallaby'运行javascript函数;s执行_脚本不工作 系统_Phantomjs_Elixir_Phoenix Framework_Wallaby - Fatal编程技术网

Phantomjs 使用wallaby'运行javascript函数;s执行_脚本不工作 系统

Phantomjs 使用wallaby'运行javascript函数;s执行_脚本不工作 系统,phantomjs,elixir,phoenix-framework,wallaby,Phantomjs,Elixir,Phoenix Framework,Wallaby,OSX v10.13.4/Elixir v1.6.5/OTP 19/Phoenix 1.3.2/Wallaby 0.19.2/PhantomJS 2.1 问题 下面的代码用于测试 execute_script(session, "localStorage.setItem('test', 'foo'); return localStorage.getItem('test');") 但是,如果我调用与Phoenix应用程序的app.js内部名为get_test()的函数中完全相同的方法 fun

OSX v10.13.4/Elixir v1.6.5/OTP 19/Phoenix 1.3.2/Wallaby 0.19.2/PhantomJS 2.1

问题 下面的代码用于测试

execute_script(session, "localStorage.setItem('test', 'foo'); return localStorage.getItem('test');")
但是,如果我调用与Phoenix应用程序的
app.js
内部名为
get_test()
的函数中完全相同的方法

  function get_test() {
    localStorage.setItem('test', 'foo'); 
    return localStorage.getItem('test');
  }

  window.get_test = get_test
并在我的测试套件中运行以下命令

execute_script(session, "return get_test();")
我得到
{:error,:obclusted}

我在同一个代码上尝试了selenium,效果很好。然而,出于某种原因,在PhantomJS中,似乎找不到我们自己创建的函数

我错过什么了吗?我注意到在wallaby中的execute_脚本测试中没有调用专门创建的函数的测试

类似的测试

其中,我在
本地存储测试中添加了以下内容,以验证我没有发疯

@function_script """
  function get_tester() {
    localStorage.setItem('tester', 'foo');
    return localStorage.getItem('tester');
  }

  return get_tester();
"""

session
  |> visit("index.html")
  |> execute_script(@function_script, fn(value) -> send self(), {:callback, value} end)

assert_received {:callback, "foo"}
就这样过去了。这显然是我的应用程序出了问题。也许是幻影形态

更新:


虽然没有直接提到,但我已经将范围缩小到libsodim没有正确加载phantomjs。回到调试的基础。写的JS没什么问题。值得肯定的是,我现在有了一整套很酷的测试库和一些很酷的测试工具。

…或者拼写
execute_脚本(会话,“reutrn get_test();”)
似乎拼写错误了
return
。很抱歉出现了拼写错误和错误,但这不是问题所在。我想知道这是否是一个时间问题,页面加载是否正确