Do you have questions ? We got the answers!

Ask a question:

How to upload a file on browserstack with selenium scripts?

Solved 1 Answers 502 Views
I am using browserstack with selenium. but i am unable to upload any file/image on browserstack. Do let me know how i can upload a file/image on browser stack.

I am using a third party tool name 'AutoIT' on my system to upload any file/image, but it is not working on browserstack. Please help me as soon as possible.

1 Answer

Best answer

When you execute tests on browser stack, you are actually executing on a remote grid. Everything happens via JSON over HTTP protocol. So, you can you execute any executable file on their remote machine.

AutoIT executes on local machine. For remote machine, you will have to upload file via JavaScript by altering existing elements on the page.

Can you edit this question and update below things?

  • HTML source of the page.
  • Screenshot of the page.
  • And your existing code using which you are uploading the image.
answered Jan 6 by stbadmin (4,970 points)
selected Mar 3 by stbadmin
commented Jan 6 by Vipul Sharma (322 points)
<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="fnApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="fnApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="fnApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="fnApp" class="no-js"> <!--<![endif]-->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base href="/">

    <link rel="shortcut icon" type="image/png" href="/images/favicon.png"/>
    <!-- 3rd css -->
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/wro/allLibs.css">
    <!-- Our css-->
    <link rel="stylesheet" href="/wro/all.css">
    <link href="" rel="stylesheet">

    <!-- Google analytics -->
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

        ga('create', 'UA-71082601-1', 'auto');
        ga('send', 'pageview');

    <script type="text/javascript">
      _atrk_opts = { atrk_acct:"mFGjo1IW18106C", domain:"",dynamic: true};
      (function() { var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; as.src = ""; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(as, s); })();
    <noscript><img src="" style="display:none" height="1" width="1" alt="" /></noscript>

<div growl></div>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="">upgrade your browser</a> to improve your experience.</p>
<div fn-header></div>
<div fn-footer></div>

<script src="/wro/allLibs.js"></script>

<script type="text/javascript" src=""></script>
<script src="/app/app.jsp"></script>
<script src="/wro/all.js"></script>
<script type="text/javascript" src="/scripts/html2canvas.js"></script>
<script type="text/javascript" src=""></script>
<script src=""></script>
commented Jan 6 by Vipul Sharma (322 points)
Screenshot ref:
commented Jan 6 by stbadmin (4,970 points)
I see your screenshot. Usually so far we are executing this kind of test cases in local grid where we can have our own executable running. So far browser stack does not support uploading of file and execution of file in their VM. Even if you could figure out JavaScript which takes file to upload. It will be very tedious to upload file to VM. So, test case like this has to be executed on local machine or local grid.

Hope that answers your question.
commented Jan 9 by Vipul Sharma (322 points)
Thank you sir for such a good information.
Please can you tell me, how i can use javaScript to upload the file?
commented Jan 12 by Vipul Sharma (322 points)
edited Jan 12 by Vipul Sharma
Hi Sir, i found the solution for this problem.

((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
commented Jan 12 by stbadmin (4,970 points)
Thank you for posting your solution. You can not really use JavaScript to upload file. Uploading of file is prevented to avoid possible hacking on the computer.

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 364 pointssumitkumarwatts

    0 questions 14 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments