[Selenium] Upload File on Remote Node Machines
Posted mastermonkintemple
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Selenium] Upload File on Remote Node Machines相关的知识,希望对你有一定的参考价值。
Problem:
In web UI automation testing, we always need to upload files, it will work well on local machines, but doesn‘t work on remote node machines when using Seleniuim Grid to run.
Solution:
No
|
Description
|
Recommendation Index
|
---|---|---|
1 |
1.Use PathUtils to get file‘s path under project 2.Convert input WebElement to RemoteWebElement 3.Call setFileDetector for the RemoteWebElement 4.Call sendKeys for input WebElement Note: for input element |
|
2 |
1.Copy upload file to a share folder 2.Call sendKeys with above file path in share folder |
Code:
Solution 1:
String filePath = pathUtils.getFilePathFromResources(fileName); public void uploadDocument(String filepath) { WebElement button = page.getUploadDocument(); ((RemoteWebElement) button ).setFileDetector(new LocalFileDetector()); button.sendKeys(filepath); }
Solution 2:
以上是关于[Selenium] Upload File on Remote Node Machines的主要内容,如果未能解决你的问题,请参考以下文章
Warning: File upload error - unable to create a temporary file in Unknown on line 0
Warning: File upload error - unable to create a temporary file in Unknown on line 0 的解决办法
Selenium WebDriver: Java: Mac OS X: how control file upload automation for CuteWebUI_Uploader_Resour
Laravel File Upload with Ajax Show 405 Method Not Allowed Error on Large File Size 20 MB