File Upload using Robot Class in Selenium

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Please use the following link to install the Katalon Studio:
    katalon.com/si... Check Tubebuddy Features Here:
    www.tubebuddy.... Facebook : / automationtesting2016
    Linkedin : / krishnasakinala
    Google+ : plus.google.co...
    Twitter : www.linkedin.c...
    automationtesti...
    File Upload using Robot Class in Selenium will discuss about how we can upload a file into web application while automating the application using selenium webdriver. As we know that selenium webdriver automates only browsers (i.e. web applications only). But sometimes we might need to automate windows based applications/popups such as upload a file or download a file etc…
    But selenium can not handle these kind of scenarios. So, we will use some third party tools to automate these type of functionality. Especially uploading a file is one of the scenarios we will face while automating most of the applications. For this we will depend mostly some third party tools like AutoIt and Sikuli.
    But in this blog we will NOT look into Sikuli or AutoIt to automate file upload functionality in selenium webdriver. Instead we will see one of the Java classes called Robot. Robot is a class in the AWT package of Java, by using this we can handle window based applications/popups. Now we use this provision to automate file upload functionality in selenium webdriver.
    If you use some third-party tools, those are extra burden to the code or framework. And sometimes these are not compatible with the tools which we use to build the application.
    So, we can use this Robot class to avoid those kind of scenarios. Basically Robot class will simulate the Keyboard and mouse actions. So, we can use the Robot class methods to handle these kind of scenarios.

КОМЕНТАРІ • 109

  • @user-mc1ll1fk9z
    @user-mc1ll1fk9z Рік тому

    thanks it was a great help god bless u Krishna

    • @KrishnaSakinala
      @KrishnaSakinala  Рік тому +1

      Thanks *priyanka patekar* for your great comment on file upload using robot class in selenium java.
      Please like, share the video and subscribe to the channel for interesting updates.

  • @gayathrip8242
    @gayathrip8242 2 роки тому

    Thank you for such a wonderful video it's very helpful for me....

  • @sayasawant12
    @sayasawant12 3 роки тому +1

    Works Perfectly thank you

  • @GurudattaPraharaj
    @GurudattaPraharaj 7 років тому +1

    thanks robot class seems better than autoIT. please make a video on mouse operations using robot

  • @shahzaibidrees2132
    @shahzaibidrees2132 2 роки тому

    It's very helpful.

  • @praveenpatil5140
    @praveenpatil5140 2 роки тому

    Thank you so much sir.

  • @praneethgandra9630
    @praneethgandra9630 5 років тому

    Very good explanation , very clear

    • @KrishnaSakinala
      @KrishnaSakinala  5 років тому

      Thanks for the feedback *Praneeth Rao*
      Please subscribe the channel and keep visiting ... :)

  • @priyadarshi786
    @priyadarshi786 6 років тому

    Thanks man . Nice explanation. I was fed up with upload. Now it works , thanks to you :)

  • @manikantanvsr8943
    @manikantanvsr8943 4 роки тому

    Awesome Explanation

  • @rajasrim6573
    @rajasrim6573 7 років тому +2

    Hi Krishna,
    Thanks a lot for the video.Robot class is simple compared to AutoIT.But what if screen gets locked? Will the script run Successfully?

  • @saiadvikcherivirala7743
    @saiadvikcherivirala7743 3 роки тому +1

    Hi, I have used the similar code. Locally working fine :).. However, when execute the code from Jenkins it fails as we are not connected to machine. please suggest some approach way to work the file upload, when execute from Jenkins.

    • @rajaea1008
      @rajaea1008 2 роки тому

      I am also facing the same issue do you have any solution

    • @InduMusuvathiDevendran
      @InduMusuvathiDevendran Рік тому

      @@rajaea1008 did anyone fine a solution for this question?

  • @sheeraz162006
    @sheeraz162006 7 років тому

    This is awesome , thanks Krishna for great video

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      Thanks for the feedback *sheeraz 162006*
      Please subscribe to the channel and keep visiting... :)

  • @kowshikgowtham1426
    @kowshikgowtham1426 6 років тому

    It was very useful instead of using autoit ,please make a mouse operation using coordinates and using slider

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Thanks for the feedback *kowshik gowtham*
      Yeah, will make videos on those also in near future.
      Please subscribe to the channel and keep visiting ... :)

  • @rajalakshmis201
    @rajalakshmis201 5 років тому

    Clearly explained.. Thanks

    • @KrishnaSakinala
      @KrishnaSakinala  5 років тому

      Thanks for the feedback *RajaSri S*
      Please subscribe to the channel and keep visiting ... :)

  • @ranjeet99mishrarock
    @ranjeet99mishrarock 3 роки тому

    Thanku sir

  • @DhruvPatel-oz1gj
    @DhruvPatel-oz1gj 4 роки тому

    Great Explanation Sir!!!! This helped me a lot

    • @KrishnaSakinala
      @KrishnaSakinala  4 роки тому

      Glad to hear that, Please subscribe to the channel and keep visiting😀

  • @classicsneverdie0
    @classicsneverdie0 6 років тому +2

    Hi Krishna, thanks for the lesson it was really good and it worked perfectly on my test cases. I have one question about it. It worked fine in my local machine but how would this work in a continuous integration process? If I have to run this on Jenkins the results would be the same? Thank you and congrats again.

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      I never tried. Will let you know when I do it.

    • @classicsneverdie0
      @classicsneverdie0 6 років тому

      I appreciate that. Your video helped me out so much with an issue I was facing and being disturbed for weeks. But I still have the CI process I have to complete and I'm not sure how to handle it using the same process you used here.
      Thanks again for answer me back.

    • @srihari1965
      @srihari1965 5 років тому

      Krishna Sakinala I’m facing the same issue. On local it is working fine but when the script runs on Jenkins it fails. Is there a solution? Thank you!

    • @InduMusuvathiDevendran
      @InduMusuvathiDevendran Рік тому

      @@KrishnaSakinala Hi Krishna I'm facing same issue. any solution to run in jenkins as well?

  • @gandharavkatyal822
    @gandharavkatyal822 7 років тому

    Thanks sir :) , nice video on robot class

  • @qatrata4814
    @qatrata4814 5 років тому

    Thanks, it's Very useful video. it's really working;

    • @KrishnaSakinala
      @KrishnaSakinala  5 років тому

      Thanks for the feedback.
      Please subscribe to the channel and keep visiting.

  • @krunal11127
    @krunal11127 5 років тому +1

    What to do when element.sendkeys(path) not working for file upload

  • @cjeyaraman
    @cjeyaraman 5 років тому

    Good explanation.

    • @KrishnaSakinala
      @KrishnaSakinala  5 років тому

      Thanks for the feedback *Later*
      Please subscribe to the channel and keep visiting.
      Like the videos and share the videos.

  • @kannansekar6641
    @kannansekar6641 5 років тому

    Works Perfectly bro. Thanks for the code :)

  • @kshipra4504
    @kshipra4504 3 роки тому

    which is better approach to use--AutoIT / Sikuli / Robot class

  • @sarafrajbukhari4310
    @sarafrajbukhari4310 2 роки тому

    Hii krishna I would like to know that if I want to press down aero key multiple times using robot or sendkeys ?
    In have desktop app and if I run using send keys or robot class that down aero run for 5 to 6 times but I have to run it more than 20 times...

  • @yogeshkumars5571
    @yogeshkumars5571 5 років тому

    Thank you so much ur code is working fine

  • @abhisekbanerjee3369
    @abhisekbanerjee3369 3 роки тому

    Thank you sir. Can you please tell us if it will work.in linux ? If not,what to do please.

  • @AjaySingh-pr6ij
    @AjaySingh-pr6ij 6 років тому +1

    How to handle download pop in ubuntu as well as window OS in single script ?

    • @gasparcoding
      @gasparcoding 5 років тому

      the best possibility is to do this with the robot class in the terminal, for example with wget or curl. I have a video of the java robot class with more examples on my channel

  • @srikb9541
    @srikb9541 7 років тому

    Thanks a ton! This helped me a lot..

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      Thanks for the feedback *Srik B*
      Please subscribe to the channel and keep visiting... :)

  • @InduMusuvathiDevendran
    @InduMusuvathiDevendran Рік тому

    Can anyone please tell, how to use Robot class in jenkin? test cases are failing in pipeline but it is working fine in local

  • @EknathRao
    @EknathRao 7 років тому

    Hi Krishna, Thanks for new video. but I can't understand the two lines of code. Can you please explain more about to got cleared on all the classes and methods you hae used in those 2 lines.

    • @EknathRao
      @EknathRao 7 років тому

      ok. If control is not on the filename then how to handle

    • @manishanand3276
      @manishanand3276 7 років тому

      i want to know the content of clean.bat file.

  • @agirumounika2629
    @agirumounika2629 4 роки тому

    I have followed the steps as mentioned ,But file path is not entering in the dialog box after clicking on browse button in my application.Could you please help on this

  • @sivaranim5680
    @sivaranim5680 4 роки тому

    Hi thanks for the video... I tried your code... But am getting Java. Awt. Headless exception at toolkit line.... Could you pls help me on this?

  • @kishoripatil2302
    @kishoripatil2302 Рік тому

    I have created generic method for file upload using the robot class file uploaded for the first time but the second time the dialogue box is not closed can you give me the solution for this?

  • @sijijaison2282
    @sijijaison2282 3 роки тому

    Thanks ..I tried with multiple file upload using Robot class but I am getting invalid file .Could you please help on this

  • @jenkinsalert7929
    @jenkinsalert7929 4 роки тому

    Thanks a ton :)

  • @hamsaveni2123
    @hamsaveni2123 4 роки тому

    Hi sir nice video. But how to use the robot class for file upload in mac

  • @radhamanogari6024
    @radhamanogari6024 4 роки тому

    Thanks Krishna, for nice explanation. But when I tried to use the robot class to upload the file I am facing the below issue.
    I could not able to access other applications when the script fails or if I terminated the execution before the robot class executes, why I am suspecting this reason could be robot class, without robot class in my script I have terminated the script n number of times where I want and continue to proceed further. But now even I could not able to access none of the applications in my system.Please can you help me to resolve this issues?

  • @ankitshrivastava1772
    @ankitshrivastava1772 3 роки тому

    Hello i am using java 11 and in the code data: "/home/ankit/Desktop/Access/ankit.jpg" it is showing the error for data in the eclipse .

  • @omkomal2010
    @omkomal2010 7 років тому +1

    Hi Krishna, My issue is when I click on upload, the open dialog box does not have input option, bcoz of ubuntu system. Can you please how to handle this situation?

    • @srihari1965
      @srihari1965 5 років тому

      Komal Pandey hey I’m facing this issue. Is there any way to upload file on Ubuntu system??

  • @ramesh.dumpati5935
    @ramesh.dumpati5935 3 роки тому

    Unable to import files with Robot due to issues with access to the clipboard when Windows is locked.
    Getting "java.lang.IllegalStateException: cannot open system clipboard" error when windows is locked. It is working fine when windoes is unlocked. Can you please give a suggestion to fix it?

  • @himats7195
    @himats7195 2 роки тому

    Will this work on remote machine

  • @dancing_frank_lee
    @dancing_frank_lee 6 років тому

    great tutorial!!!!!!!

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Thanks for the feedback *DANCE2EXPRESS*
      Please subscribe to the channel and keep visiting ... :)

  • @sammy22391
    @sammy22391 6 років тому

    Hi, this was a great video, I have concern If I want to upload multiple files how would I do that If I use robot class the lines of code in my test case will increase suppose I have to upload 30 files, same with autoIT right ,,, i would have to pass the paramaters during run time, so is there any other method to upload multiple files apart from autoIt , sikuli, robot class and winnium library.,.... please help ... your help will be very much appreciated ... thanks in advance for your response

  • @PaytmBadshah
    @PaytmBadshah 2 роки тому

    Hey buddy how to make this work in python Robot Frame work?

  • @prabhjotahluwalia5040
    @prabhjotahluwalia5040 4 роки тому

    hi sir, can you please tell how can we implement the same using javascript/protractor?

  • @jajatikesharisahoo8628
    @jajatikesharisahoo8628 6 років тому

    Awesome........

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Thanks for the feedback *jajati keshari sahoo*
      Please subscribe to the channel and keep visiting ... :)

  • @tulasivurukonda1238
    @tulasivurukonda1238 3 роки тому

    How can we upload multiple files using robot class

  • @jaydeepkumarpal2334
    @jaydeepkumarpal2334 6 років тому

    nice video

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Thanks for the feedback *Jaydeep kumar pal*
      Please subscribe to the channel and keep visiting ... :)

  • @atulbankar1486
    @atulbankar1486 Місяць тому

    its not working while running script on jenkins server plz give any solution

  • @sachinsusmi1279
    @sachinsusmi1279 6 років тому

    Hi krishna, Thanks for your video.. I have tried it with my application it's working fine, but sometimes the default cursor is not in the file name input box, it's in search bar on the top right corner of our desktop window, so it puts the path over there and got failed for me,.. My question is how to set or check the default cursor in the file name box or not, before i put the path of that file in it? Then it makes sense for my application to work i think... Give me an idea krishnan.. Please..

    • @ankushsingh4609
      @ankushsingh4609 2 роки тому

      Have you found this solution i am getting th same issue cursor not set in file name

  • @krisshcryptoworld6046
    @krisshcryptoworld6046 7 років тому

    Can you please help without copy pasting the file-path .
    Instead pass the file path from a variable

  • @dineshbabu3938
    @dineshbabu3938 6 років тому

    Hello Krishna, Could you please make a video how to verify file is uploaded/downloaded successfully in selenium webdriver java.

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Sure *dinesh babu* . I am planning the same. So, please let me know the sites where we can do upload and download then will try to do the same on those sites.

    • @dineshbabu3938
      @dineshbabu3938 6 років тому

      You can use this site "toolsqa.com/automation-practice-form/"

  • @user-vi1tx4nv1b
    @user-vi1tx4nv1b 6 років тому

    Do they have the same way in MacOS?

  • @parveenchauhan5132
    @parveenchauhan5132 5 років тому

    How to automate file upload scenario on ubuntu system any idea?

  • @mariomorle2452
    @mariomorle2452 6 років тому

    thanks

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Thanks for the feedback *Mario Morle*
      Please subscribe to the channel and keep visiting ... :)

  • @larrywoo1982
    @larrywoo1982 7 років тому

    my situation is upload file is button, not , Robot is java version, but I am using python code, is there any solution to upload file with selenium(python version) in Linux?

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      Hi *Larry Woo*
      I am extremely sorry that I never worked with Python. So, I can not help you on this :(
      Please do visit for the updates and subscribe the channel.

  • @nikhilreddy8839
    @nikhilreddy8839 5 років тому

    Can we upload multiple files at at time by using Robot class?

  • @manishanand3276
    @manishanand3276 7 років тому

    Its awesome . Can you plz paste the bat file content?

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      Which bat file you asking about?

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      Thanks for the feedback. Please subscribe to the channel and keep visiting... :)

  • @aravinda4199
    @aravinda4199 Рік тому

    Hi , While clicking on Browse button ,I am getting below error why?(I used id="imagesrc")
    Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Cannot click

  • @mohammedbaig5793
    @mohammedbaig5793 Рік тому

    Is robot class specific to firefox browser? Or we can use it for chrome too?pls confirm

  • @sandy35033
    @sandy35033 6 років тому

    How to upload multiple files together?

  • @sunkarimounika6229
    @sunkarimounika6229 6 років тому

    Hello,How to Upload Multiple files using robot class.I have two files in one folder with extensions .csv and .xlsx.Can you help me how to upload two files together.

  • @msraju2326
    @msraju2326 2 роки тому

    Hi Krishna, Does it work in both Mac and Windows OS. ???

  • @ankitshrivastava1772
    @ankitshrivastava1772 3 роки тому

    Hello Sir, will it work for Ubuntu Machine?

  • @EntertainmentWorld-qg3gc
    @EntertainmentWorld-qg3gc 7 років тому

    If we are using selenium with c# then what is the process to follow for uploading the file.

    • @KrishnaSakinala
      @KrishnaSakinala  7 років тому

      I am not sure.
      I think we have same kind of API in C# also.
      Will let you know if I find anything.

  • @nhphihung
    @nhphihung 7 років тому

    It not works for me. I run the TC in selenium container

  • @challaprasad42
    @challaprasad42 6 років тому

    will this work in linux os please suggest

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому +1

      I tried with windows and mac and it is working fine in both OS. Not sure about Linux. Please check and let me know... :)

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Sorry man I tried only with windows not with Mac. Sorry for the previous comment.

    • @challaprasad42
      @challaprasad42 6 років тому

      @@KrishnaSakinala hi thanks for the response annaya. Yes it's working in Linux but we need write code for based on the functionality means in Windows when you click on browse option courser pointing file upload text box but in Linux we need see who it is then write code based on that.

    • @KrishnaSakinala
      @KrishnaSakinala  6 років тому

      Great...

    • @prasannapujar4484
      @prasannapujar4484 5 років тому

      @@challaprasad42 : Hi Challa prasad
      do you mean in linux machine by default cursor is not pointing at file upload path ? How did you handle this ? you comment please pseudo code ?

  • @vikhyat1983
    @vikhyat1983 5 років тому

    Vikhyat