1
我使用plupload可以跨瀏覽器上傳文件。我的HTML看起來像這樣
量角器找不到元素
<div id="fileInputs">
<div id="html5_18fclrb4o1jgqiufhe6hpghk28_container" class="moxie-shim moxie-shim-html5" style="position: absolute; top: 0px; left: 0px; width: 120px; height: 33px; overflow: hidden; z-index: 0;">
<input id="html5_18fclrb4o1jgqiufhe6hpghk28" type="file" style="font-size: 999px; opacity: 0; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" multiple="" accept="">
</div>
</div>
所有的內嵌樣式上飛以及由末席和plupload輸入類型文件元素生成。我無法通過id來引用,因爲id會隨即生成並始終不同。我的測試基本上是試圖找到該輸入併發送某些鍵上傳文件
var container = element(by.css('.moxie-shim'));
container.find('input').then(function(input){
input.getInnerHtml().then(function(inner){
console.log(inner);
});
input.sendKeys('/Users/me/Desktop/toUpload.pdf');
})
我得到的日誌,這證實了我的確有輸入的輸入。但是,這是我一直得到
UnknownError: unknown error: cannot focus element
(Session info: chrome=32.0.1700.102)
(Driver info: chromedriver=2.8.241036,platform=Mac OS X 10.9.1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 36 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'climboid.local', ip: '10.0.0.3', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'
Session ID: d11f5fe29cf2bb6944820646594d7b24
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/1s/cnypppy93gz6d0tvwbfc2f7h0000gn/T/.org.chromium.Chromium.QcT29B}, rotatable=false, locationContextEnabled=true, version=32.0.1700.102, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
任何幫助的錯誤是非常讚賞。謝謝!
Wlingke你是一個天才要比!謝謝! – climboid