Pular para o conteúdo principal

uploadFile

Faz upload de um arquivo para o servidor Selenium Standalone ou outro driver de navegador (por exemplo, Chromedriver ou EdgeDriver) usando o comando file. Nota: este comando só é suportado se você usar um Selenium Hub, Chromedriver ou EdgeDriver diretamente.

Nota: este comando usa um recurso de protocolo não oficial que atualmente só é suportado no Chrome e ao executar um Selenium Grid.

Uso
browser.uploadFile(localPath)
Parâmetros
NomeTipoDetalhes
localPathstringcaminho local para o arquivo
Exemplo
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()
});
Retorna
  • <String> return: URL remota

Welcome! How can I help?

WebdriverIO AI Copilot