1

What is the difference between using sendkeys() and autoit, which helps to upload images.

2 Answers 2

1

Sendkeys( ) is a command used for sending input from the keyboard e.g. for entering some value in the input field, the keys/values typed inside the Sendkeys( ) command will be entered in the respective field during execution of test for web based applications. They are confined to the browser. Using SendKeys() command you can directly set the path of the file to be uploaded in the respective Upload file field, so when this line of code is executed your upload field will have the specified file as attached but it will not open the windows explorer for finding and attaching the file. It may get fail sometimes, depending upon the application (although in the tests created by me, I haven't seen it getting failed) but have seen related posts over SO and SQAForums.

While AutoIt is used to interact with the desktop to do things like downloads & uploads. Automating these sorts of workflow is tricky in Selenium. Using AutoIt (3rd party) in Selenium helps in recording and executing desktop based scenarios. You can create your desktop interaction scripts in AutoIT and then call it from your Selenium test scripts. This is a more efficient method of handling Windows pop-ups and dialogues.

0

It are two ways of populating an HTML INPUT type FILE form field.

  • SendKeys works on all operating systems and for all browsers where you can set the internal value of the INPUT field
  • Auto-IT works only on Windows and should only be used for browsers where you cannot manipulate the internal INPUT field value

Not sure why people would prefer the Auto-IT version, I would always try and get the SendKeys version working. I would get developers to change the file upload to use INPUT, so that the SendKeys version works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.