Create and upload a file on selenium grid

你说的曾经没有我的故事 提交于 2019-11-29 07:26:09

It's actually pretty simple once you know how, just set a local file detector.

import org.openqa.selenium.remote.LocalFileDetector
import org.openqa.selenium.remote.RemoteWebDriver

WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox());
driver.setFileDetector(new LocalFileDetector())

Then just upload as normal and Selenium will fire the file across the wire to the node.

You can do it in normal way as you create a file on local machine. See below,

File file = new File("\\\\00.00.00.00\\c$\\somefile.txt");
file.createNewFile();

This will create a file called somefile.txt in 'C' drive on the remote machine. Change the IP address to your remote machine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!