I am trying to upload files to my web application once the windows dialog box opens. I do not have the option to directly pass the file path to a text box so i have use the windows file upload alone. Kindly clarify or enlighten me on this.
WebUI.uploadFile(findTestObject('Object Repository/Page1/SelectFilesButton'), 'C:\\\\Users\\\\Derek\\\\Desktop\\\\AAA\\\\BBB\\\\AAA.csv')
I am using the above code but i get the error “Cannot focus on object” and i am not sure which test object to pass in the above code? Should i be using the test object of the button which invokes the file upload popup?
Thanks in advance.
could you share with us your Test Object and also a snippet of HTML code with your upload button?
@Marek_Melocik Thank you for looking in to it, I have achieved the above scenario using another program.
I see you’ve found a workaround, but just as an FYI, generally when you try to interact with a dialog that appears as a new window, you will need to switch focus to the window first (this is probably why you were getting the error you mentioned). You can do it as follows:
Where ‘index’ is the zero-based index of the newly-opened dialog (in most cases, you would pass a ‘1’ here). Or, if you know the title or the URL of the new window, you could use these:
Once you’ve switched focus to the appropriate window, Selenium has the proper context for finding and interacting with elements in the dialog window.