मुख्य सामग्री पर जाएं

फ़ाइल अपलोड करें

Selenium Standalone सर्वर या अन्य ब्राउज़र ड्राइवर (जैसे Chromedriver या EdgeDriver) पर file कमांड का उपयोग करके फ़ाइल अपलोड करता है। नोट: यह कमांड केवल तभी समर्थित है जब आप Selenium Hub, Chromedriver या EdgeDriver का सीधे उपयोग करते हैं।

नोट: यह कमांड एक अनौपचारिक प्रोटोकॉल सुविधा का उपयोग करती है जो वर्तमान में केवल Chrome में और Selenium Grid चलाते समय समर्थित है।

उपयोग​
browser.uploadFile(localPath)
पैरामीटर्स​
नामप्रकारविवरण
localPathstringफ़ाइल का स्थानीय पथ
उदाहरण​
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()
});
रिटर्न​
  • <String> return: रिमोट URL

Welcome! How can I help?

WebdriverIO AI Copilot