Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://www.youtube.com/watch?v=7a8IofqBNo4&t=1s
- Hi Ashu. great code! Thanks for sharing.
- I have successfully applied your selenium method for the data entry part, but now I can't upload 2 files on two separate uploading prompt buttons on the same page, because the script of this tutorial is for IE.
- Does it work with your selenium method?
- Is it possible to upload from paths as input in excel cells—not hard-coded/strings files paths?
- I mean if I prepare a list of files paths from the same folder and input them into excel cells and then take the values of the excel cells from the cells references as per your example?
- For example:
- I manually paste the 1st file path into cell A2, Sheet "Data", same Workbook as the VBA Code, the path of 2nd file into A3:
- A2 cell (string) value = C:\Users\XXX\Pictures\text1.txt
- A3 cell (string) value = C:\Users\XXX\Pictures\text2.txt
- Can I make something like:
- Sub uploadFiles()
- Dim robot As New ChromeDriver, Keys As New Keys
- 'OPEN the webpage: https://www.automationandagile.com/p/sample-form.html
- robot.Get "https://www.automationandagile.com/p/sample-form.html"
- 'WAIT 3 seconds for the webpage to load and then execute the following code
- robot.Wait 3000
- 'CLICK the webpage's 1st upload prompt button
- robot.FindElementByXPath("//*[@id='WEBUPLOADBUTTON1']").Click
- 'the path of the VBS file on my C Drive AS constant/hard-coded "Variable" string
- strFile = "C:\Excel_Automation\Files\FileUpload.vbs"
- 'the path of the 1st file (text1.txt) on my C Drive to be uploaded, but as input into cell A2 of the current excel workbook, of Sheet named "Data" AS dynamic/variable excel cell reference
- strUploadFile1 = (ThisWorkbook.Sheets("Data").Range("A2").Value)
- 'syntax of the VBS uploading method (Shell "_exescript_" & VBS FIle Path & " space_" & _Uploadfile )
- Shell "wscript.exe " & strFile & " " & strUploadFile
- 1
- 'CLICK the webpage's 2nd upload prompt button
- robot.FindElementByXPath("//*[@id='WEBUPLOADBUTTON2']").Click
- 'the path of the 2nd file (text2.txt) on my C Drive to be uploaded, but as input into cell A3 of the current excel workbook, of Sheet named "Data" AS dynamic/variable excel cell reference
- strUploadFile2 = (ThisWorkbook.Sheets("Data").Range("A3").Value)
- 'syntax of the VBS uploading method (Shell "_exescript_" & VBS FIle Path & " space_" & _Uploadfile )
- Shell "wscript.exe " & strFile & " " & strUploadFile
- 2
- End Sub
- Would it work like this? Anything missing? Do you see a better way to do it?
- Would you please make a video to upload 2 files with selenium on Chrome Browser?
- Thanks for your help.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement