【问题标题】:File uploading error in codeception?代码接收中的文件上传错误?
【发布时间】:2015-08-28 12:20:01
【问题描述】:

我正在尝试将文件上传到几个输入元素。这些输入的 id 属性总是随机生成的,所以我从我的辅助函数中收到一个 RemoteWebElements 列表:

function getInputFields() {
    $inputs = $this->getModule('WebDriver')->_findElements(['xpath' => "//input[@type='file']"]);
    return $inputs;
 }

然后,在 Cept 中,我尝试上传文件,将 ID 插入 XPath 字符串

$pass = $I->getInputFields();
$path_to_input1 = "//*[@id='" . $pass[0]->getAttribute('id') ."']";
$I->attachFile($path_to_input1, '1.jpg');

我很确定输入元素存在,并且我得到了正确的 ID,通过调试输出检查。 得到这个:

[ERROR - 2015-08-28T11:15:35.801Z] RouterReqHand - _handle.error - {"stack":"\tat _uploadFile ([native code])\n\tat \n\tat _postUploadFileCommand (:/ghostdriver/request_handlers/session_request_handler.js:212:30)\n\tat _handle (:/ghostdriver/request_handlers/session_request_handler.js:198:35)\n\tat _reroute (:/ghostdriver/request_handlers/request_handler.js:61:20)\n\tat _handle (:/ghostdriver/request_handlers/router_request_handler.js:78:46)","line":431,"sourceURL":""}

[Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'Error - incompatible type of argument(s) in call to _uploadFile(); candidates were
_uploadFile(QString,QStringList)'

你能帮帮我吗,这里的陷阱在哪里?

【问题讨论】:

    标签: php testing codeception


    【解决方案1】:

    因此,从 PhantomJS 切换到 Selenium 服务器可以解决该问题。

    我在 github 上发现了这个问题,看来下一版 PhantomJS 会修复:https://github.com/ariya/phantomjs/issues/12506

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 2015-10-30
      • 2018-03-03
      • 2016-11-10
      • 2014-08-24
      • 2015-08-27
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多