Advertisement
Guest User

Init custom browser in Ranorex

a guest
Oct 29th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var RMRanorexAttacher = {
  2.     //Add document inside browser to Ranorex, so you can access DOM of this document.
  3.     AttachBrowser: function(browser) {
  4.         var rxResolverCallback = function(browserObj)
  5.                 {
  6.                     // refresh window from tab
  7.                     return browserObj.contentWindow;
  8.                 };
  9.                
  10.         var rxCallback = function(str, arg1, arg2, arg3)
  11.                     {
  12.                         try
  13.                         {
  14.                             if (str == "SelectTab")
  15.                             {
  16.                                 //No tabs support
  17.                                 return null;
  18.                             }
  19.                             else if (str == "CloseTab")
  20.                             {
  21.                                 //No tabs support
  22.                                 return null;
  23.                             }
  24.                             else if (str == "GetZoom")
  25.                             {
  26.                                 return arg1.markupDocumentViewer.fullZoom+'';
  27.                             }
  28.                             else if (str == "PerformClick")
  29.                             {
  30.                                 ev = document.createEvent('MouseEvents');
  31.                                 ev.initMouseEvent('click', true, false, arg1, 1, 0, 0, 1, 1, false, false, false, false, 0, null);
  32.                                 arg2.dispatchEvent(ev);
  33.                             }
  34.                         }
  35.                         catch(e)
  36.                         {
  37.                             return null;
  38.                         }
  39.                     };
  40.  
  41.         const cid = "@ranorex.com/RanorexAutomation3;1";
  42.         var obj = Components.classes[cid].createInstance();
  43.        
  44.         var rxAutomation = obj.QueryInterface(Components.interfaces.IRanorexAutomation3);
  45.  
  46.         rxAutomation.AddTabWindow(window, browser, rxCallback, rxResolverCallback);
  47.         rxAutomation.SetSelectedTabWindow(window, browser);
  48.     },
  49.  
  50.     DetachBrowser: function(browser) {
  51.         const cid = "@ranorex.com/RanorexAutomation3;1";
  52.         var obj = Components.classes[cid].createInstance();
  53.        
  54.         var rxAutomation = obj.QueryInterface(Components.interfaces.IRanorexAutomation3);
  55.  
  56.         rxAutomation.RemoveTabWindow(window, browser);
  57.     }
  58. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement