本文へ移動

uploadFile

fileコマンドを使用して、Selenium Standaloneサーバーまたはその他のブラウザー ドライバー(例:ChromedriverまたはEdgeDriver)にファイルをアップロードします。 *注:*このコマンドは、Selenium Hub、Chromedriver、またはEdgeDriverを直接使用する場合にのみサポートされます。

注:このコマンドは、現在Chromeでのみ、そしてSelenium Gridを実行している場合にのみサポートされている非公式のプロトコル機能を使用しています。

使用方法
browser.uploadFile(localPath)
パラメーター
名称詳細
localPath文字列ファイルへのローカルパス
uploadFile.js
import path from 'node:path'

it('should upload a file', async () => {
await browser.url('https://the-internet.herokuapp.com/upload')

const filePath = '/path/to/some/file.png'
const remoteFilePath = await browser.uploadFile(filePath)

await $('#file-upload').setValue(remoteFilePath)
await $('#file-submit').click()
});

ようこそ!お手伝いできることはありますか?

WebdriverIO AI Copilot