2015-09-28 47 views

回答

2

請參閱有關保存到磁盤How to download any file and save it to the desired location using Selenium Webdriver

我不認爲Codeception可以控制本地的「另存爲」對話框,這個前面的問題。您可以更改Firefox配置文件來保存而不用詢問,檢查PHP中是否存在文件,並在文件不存在時聲明錯誤。

如果您使用的是Cest格式,您可以在_support/WebHelper.php中做如下幫手。

<?php 
namespace Codeception\Module; 

// here you can define custom functions for WebGuy 

class WebHelper extends \Codeception\Module 
{ 

    public function seeFileExists($filename) 
    { 
     \PHPUnit_Framework_Assert::assertTrue(file_exists($filename)); 
    } 

} 

這應該允許你在你的Cest文件中做$I->seeFileExists('downloadpath/filename.txt');

有自定義的斷言的文檔http://codeception.com/docs-2.0/03-ModulesAndHelpers