Chaoui05 has asked for the wisdom of the Perl Monks concerning the following question:

Below are the additional bullets : I can get my "button" with following code :

$elem = $driver->find_element('//*[@id="file_uploader"]/div/div/div/d +iv[1]/div[1]/div/span'); $driver->mouse_move_to_location(element => $elem); # xoffset => x +, yoffset => y $driver->click_ok('LEFT'); $driver->pause(3000);

But after that, I can't get anything in Opened Window which appears to upload. How is it possible to upload a file also?

Thanks in advance !
  • Comment on How to upload a file in a test through Open Windows using Selenium::Remote::Driver Perl package
  • Download Code

Replies are listed 'Best First'.
Re: How to upload a file in a test through Open Windows using Selenium::Remote::Driver Perl package
by Corion (Patriarch) on Apr 29, 2016 at 12:34 UTC
      Yes i did it. As you can see here but it doesn't work
      my $fname = "D:/dev/t/tests/selenium/phantomjs-2.1.1-windows.zip"; my $remote_fname = $driver->upload_file( $fname ); my $element = $driver->find_element( '//*[@id="file_uploader"]/div +/div/div/div[1]/div[1]/div/span' ); $element->send_keys( $remote_fname );

        You can improve the interaction here by telling us what you tried, and how it fails to do what you expect. We cannot guess what errors you are seeing or how a specific program that you don't show us fails with a specific website that you don't show us, with an error message that you keep secret.

Re: How to upload a file in a test through Open Windows using Selenium::Remote::Driver Perl package
by stevieb (Canon) on Apr 29, 2016 at 14:09 UTC

    Corion has given you the information you need in order for you to help yourself get help.

    I'd like to say that it is considered proper etiquette when you cross-post to different sites to inform all of them that you're doing so. That way, people aren't wasting time troubleshooting something that may have been answered somewhere else.

      Just to know. What is the problem if i post my issue in different forum if i always give answer ? And another question how is it possible to add a file or a screenshot here ? Thanks

        Add file: if code or data-as-text, surround it with code tags. But be sure you've made it a small, representative sample, with any personal information redacted. A thousand bytes or so should suffice. The notion is -- reduce your problem code to something that reliably demonstrates the problem without including all the "other" important (and not so important) parts.

        Pictures are basicly no-no's here in the Monastery except one small one on your user page. While it's an imperfect solution, if the screenshot (I'm guessing, but pls confirm that you mean it's a picture of interaction with your script) can be linked from any server that's publicly accessible, including those that specialize in that sort of service.

        HOWEVER, that's frowned upon (among other reasons, because

        1. There's no assurance the picture (or file if binary) will still be on the remote server when some future reader wants to know what's in it
        2. the Monk(S) who's inclined to try to help must now visit an unknown and likely untrusted website to 'buy a pig in a poke,' i.e., your file with unknown and possibly malicious content
        3. and, assuming the aforesaid Monk(s) does so, the very process is another step that adds to the time s/he is donating to your problem.

        So better, figure out how to state your problem without requiring all that; preferably, without recourse to any external source...

        For more, please see

        And, not just BTW, while an informative subject is helpful, so is "brief." Your title is on the long side!

        ++$anecdote ne $data

        Cross posting is not a problem, but, please, state it upfront and provide the link. At least, we will not lose time asking a question to which you've already answered elsewhere, and at best, we will find out that your problem has been solved. Perhaps hours before you can report that here. Or perhaps partly solved, but just needing an additional small input. Nobody can know if you don't say if beforehand.