Forum Discussion

fayrehouse's avatar
fayrehouse
Frequent Contributor
11 years ago
Solved

Bit of an outside hope for help here (and not directly TC related per se, but...)

Hi All,



I won't go into the details of WHY I need to achieve the following here, but:



We have a web app under test, that contains a number of links that open PDF docs. I have existing TC code for handling PDFs within Adobe Reader - but these are PDFs already saved locally. By default, when I click a PDF link in the web app, it opens the PDF in the browser built in reader. I don't want this to happen - I want it to fire up Adobe Reader, so I can use my existing code.



I have a requirement to test against Chrome (latest), IE (8-11), Safari (latest), and FF (latest). Obviously, they all have different means of enabliing / disabling the various extensions / plugins etc they support. 



I need to automate this enabling / disabling. You may be wondering "why not just do that manually first" - the reason for this is that our automation is going to be run on a number of different hosts - and I want to be SURE that whatever host is set up correctly, as part of the test run.



I've found the "preferences" text file for Chrome that has the required settings - and I gather that FF does it via config files (not registry) aswell - but cannot find the required file. Not yet found the answer for IE, and not yet been brave enough to look for Safari!



So has anyone automated plugin enabling / disabling for each of the above browsers?



Please?! :)





  • Hi Steve,



    Just a quick idea: what if you will not click the link (well, all at all you are not testing that the given browser opens pdf reader when you click the link that references pdf file, are you?), but instead:

    a) (Optionally) analyse that the link has correct structure (this is to be on the safe side and guarantee (more or less) that for the correctly set browser the pdf reader should be opened);

    b) Download and save to the disk file from the link (http://support.smartbear.com/viewarticle/8999/)

    c) Explicitly start Adobe Reader from your test code;

    d) Open saved file in Adobe Reader;

    e) Proceed with your existing code :)



    Thoughts?

10 Replies

  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    You don't actually need to download the file manually before opening it in AcroRead. You can feed Acrobat Reader an URI directly! Although for some reason this doesn't work from the command line. If however you open up AcroRead, press Ctrl-O and type in the web address, the file will download silently and show up when it`s done. I think this also works with FoxIt reader.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Steve,



    Just a quick idea: what if you will not click the link (well, all at all you are not testing that the given browser opens pdf reader when you click the link that references pdf file, are you?), but instead:

    a) (Optionally) analyse that the link has correct structure (this is to be on the safe side and guarantee (more or less) that for the correctly set browser the pdf reader should be opened);

    b) Download and save to the disk file from the link (http://support.smartbear.com/viewarticle/8999/)

    c) Explicitly start Adobe Reader from your test code;

    d) Open saved file in Adobe Reader;

    e) Proceed with your existing code :)



    Thoughts?
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Steve,



    Great to hear that the idea appeared to be acceptable for your needs. :)



    > Just to check what you meant in "a)" [...]



    Yes, your understanding is correct.



    > msxml3.dll System error: -2146697191 [...]



    Unfortunately, I did not met any recommendations on how to ignore certificate errors (i.e. I just did not have such problem, not that this is not possible), sorry. But I like Hugo's suggestion to open URI from Adobe Reader. I hope that there is a chance that either Adobe Reader can be setup to ignore certificate errors or it will display some message that can be handled by the means of TestComplete.



    Really believe that you'll make all this stuff working and let us know about your success.
  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    Thanks Hugo,



    I gave it a try, but again it looks like our SSL issues are getting in the way - I initially get prompted to select a certificate (only one available, issued to me by "Communications Server" - I proceed past there, then get a "Windows Security" dialog wanting user/pass on the remote host... Which I do not have... and don't need if I paste the remote PDF URL into a browser? 



    So I'm currently back to Alexei's XMLHTTP Solution. I've discovered there is MSXML2.ServerXMLHTTP which has a "setOption" method that can be set to ignore SSL issues... but that's now just timing out on the call to the send.



    Aggghhh - so close!



    Many thanks to both you and Alexei for your ongoing support!



    Steve
  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Just a thought, but are you sure your root certificates on the client machine are up to date? I had a very similar issue with a SOAP transaction some time ago, the server had a proper certificate, but the SOAP client was failing with only some clients. Turns out these clients did not have updated root certs from Windows Update, and it just started working after that.



    If the problem is really the certificate, you could always get the sysadmin to self sign a certificate for you.
  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    Hi Alexei,



    You asked for my thoughts.



    My thoughts are "I could cry with joy" ;-)



    Ok, so *technically* this would NOT be clicking the link on the web page. However, it IS checking the link target, and I feel that's good enough!



    Just to check what you meant in "a)" - Basically, if I get the href property of the link object, an verify it ends in ".pdf" - then (in theory!) you'd like to think it is indeed a PDF to download, and from there I can follow b) - e) without problem!



    You are a star!!



    (It's just a shame (in a sense) that I have in the meantime solved my initial problem for IE, FF and Chrome - but there is seemingly NO WAY of solving it in Safari - other than your excellent solution!)
  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    Ack, I spoke too soon!



    objHTTP.send();   produces an error:



    msxml3.dll



    System error: -2146697191



    Could this be due to the fact the URL is HTTPS?



    Or perhaps the fact that the SSL certificates on our test env are invalid (I've had to code around that for the different browsers... don't get me started on why we don't just sort the certs!)??



    FYI - It looks like I have the following installed:



    MSXML 4.0 SP2 (KB954430)

    MSXML 4.0 SP2 (KB973688)



    Thanks again Alexei for your suggestion - I am sure this is the way forward once I can resolve these issues!





  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    It's our certs!



    I found a sample pdf online over https, and that worked fine...



    So - do you know a way of telling msxml to ignore cert errors?! :)
  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    Yeah the certs here are something of a "known issue" ;) I'm told a full rebuild of our test envs is in the pipeline, and the cert problems *should* get resolved then....



    I've made lots of noises in the last few days to try and get this pushed along the line a bit, so fingers crossed!