Behat附件文件不起作用

Dha*_*gam 1 behat mink

我正在使用'selenium2'驱动程序,并尝试测试文件上传表单输入字段,但得到错误

Exception thrown by (//html/descendant-or-self::*[@id = 'ImageID'])[1]
'D:/looks.jpg' does not exist on the file system
Run Code Online (Sandbox Code Playgroud)

我的代码在FeatureContex.php中如下所示

>     $page = $this->getSession()->getPage();
>     $element = $page->find('css', '#ImageID');
>     $element->attachFile('D:/looks.jpg');
Run Code Online (Sandbox Code Playgroud)

小智 5

你定义了files_path吗?我的是behat.yml.如果您已经定义了这个,那么您只提供应该在定义的文件夹中存在的文件名.

  default:
    context:
      class:  'FeatureContext'
    extensions:
      Behat\MinkExtension\Extension:
        files_path: '/var/www/project/public/images'
        base_url:  'https://local.dev'
Run Code Online (Sandbox Code Playgroud)