簡體   English   中英

Selenium,PHPUnit和AttachFile()

[英]Selenium, PHPUnit, and AttachFile()

我目前通過PHPUnit運行Selenium命令到遠程服務器。 我遇到了一個問題,我試圖將圖像上傳到輸入表單。

在我的PHPUnit中,我有命令

$this->attachFile( 'file', 'file://test.png' );

我的Selenium服務器返回錯誤

PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
java.lang.RuntimeException: Output already exists: /tmp/selenium2070373138020433468upload.

我的test.png文件目前只位於我執行.php單元測試的文件夾中。

如何通過PHPUnit和Selenium正確上傳文件並讓它不引發異常?

我有同樣的問題。 然后我發現了這篇文章: http//bitsilearn.blogspot.com/2010/03/selenium-upload-files.html

所以我沒有使用$this->attachFile('file', 'file://test.png')使用了:

$this->type('file', '/path/to/file');

它的工作原理! :)

我的經驗:文件路徑必須以file://為前綴(在Windows平台上使用)。

以下代碼有效。 試試看。

$this->byName('Name Locator')->value('/home/img/Desert.jpg');
$this->byName()->submit();
sleep(1);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM