Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
4.1k views
by The go-to Tester (324 points)
retagged by
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

1 like 0 dislike
by The go-to Tester (181 points)
selected by
 
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.
by The go-to Tester (324 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]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>FoodNiche</title>
    <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="https://vjs.zencdn.net/5.4.4/video-js.css" rel="stylesheet">

    <!-- Google analytics -->
    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

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

    </script>
    <script type="text/javascript">
      _atrk_opts = { atrk_acct:"mFGjo1IW18106C", domain:"foodniche.me",dynamic: true};
      (function() { var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; as.src = "https://d31qbv1cthcecs.cloudfront.net/atrk.js"; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(as, s); })();
    </script>
    <noscript><img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=mFGjo1IW18106C" style="display:none" height="1" width="1" alt="" /></noscript>
</head>
<body>

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

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

<script type="text/javascript" src="https://js.stripe.com/v2/"></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="https://maps.googleapis.com/maps/api/js?key=AIzaSyCWhvvcHNGEYJRTwunB_5Ar9B3paqu4Tqs&libraries=places"></script>
<script src="https://vjs.zencdn.net/5.4.4/video.js"></script>
</body>
</html>
by The go-to Tester (324 points)
by The go-to Tester (181 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.
by The go-to Tester (324 points)
Thank you sir for such a good information.
Please can you tell me, how i can use javaScript to upload the file?
by The go-to Tester (324 points)
edited by
Hi Sir, i found the solution for this problem.

((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
        Thread.sleep(2000);
        driver.findElement(By.xpath(".//*[@id='content']/div[2]/div/div[2]/div/div/form/div/div/div[3]/div[1]/input")).sendKeys("file\\path");
by The go-to Tester (181 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.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...