javascriptselenium-webdriverjspimacroswebi

How to access web page source code including CSS and JavaScript like chrome inspect element option does?


I'm trying to automate few simple clicks on SAP WebI Reports. My intention is very simple:

I'll go to http://dbie.rbi.org.in/DBIE/dbie.rbi?site=home and wait for page to be loaded. [This is required for logging in as a guest to DBIE(Database On Indian Economy : RBI's Data Warehouse)]

Then I'll view a BO ID. As soon as it's logged in I'll go to:

http://dbie.rbi.org.in/OpenDocument/opendoc/openDocument.jsp?rbiApp=true&iDocID=7557110&sType=wid&sRefresh=Yes&token=null

Above URL is a example and the format followed is like this (notice BO_ID):

http://dbie.rbi.org.in/OpenDocument/opendoc/openDocument.jsp?rbiApp=true&iDocID=BO_ID**&sType=wid&sRefresh=Yes&token=null

Now I'll wait to load the report.

After that I'll press Document button in the top left corner and save it as pdf / xls. As given in this screenshot :

file download

This entire thing I want to do non-interactively and without opening a browser. Like I want some function like :

 getBO_in_PDF_Fromat(int BO_ID)

which will do all this work in background and will download the pdf/xls in a predefined folder or that can be taken as another argument in the function.

I have tried iMacros and learning Selenium now.

Now let's discuss this in more objective way :

Option A:

iMacro script :

SET !ERRORIGNORE YES
 
CLEAR
TAB CLOSEALLOTHERS
TAB T=1
URL GOTO=http://dbie.rbi.org.in/DBIE/dbie.rbi?site=home
SET !WAITPAGECOMPLETE YES
URL GOTO=http://dbie.rbi.org.in/OpenDocument/opendoc/openDocument.jsp?rbiApp=true&iDocID=7557110&sType=wid&sRefresh=Yes&token=null
FRAME F=2
SET !WAITPAGECOMPLETE YES
'xls download'
ONDOWNLOAD FOLDER=C:\Users\igayen\Documents\DSIM\DMDD\Apps\WSS_Handler\Test\ FILE=7557110.xls WAIT=YES
FRAME F=2
TAG POS=1 TYPE=DIV ATTR=ID:IconImg_iconMenu_arrow_docMenu
SET !WAITPAGECOMPLETE NO
TAG POS=1 TYPE=DIV ATTR=ID:iconMenu_menu_docMenu_item_arrow_saveDocComputerAs
TAG POS=1 TYPE=DIV ATTR=ID:saveDocComputerMenu_item_arrow_saveXLS
ONDIALOG POS=1 BUTTON=NO
URL GOTO=http://dbie.rbi.org.in/DBIE/dbie.rbi?site=home

Option B:

Chrome Source View Method : Now if I have access to whole source code including generated JavaScript like chrome inspect element does I could have easily done the job. here is how

I'll go to chrome and do the same steps before downloading the file as mentioned earlier and after that I'll do this :

Source Search

I'll search for var strEntry = in source and will get a number [that number will be different on each session] And my pdf download link will be then

http://dbie.rbi.org.in/AnalyticalReporting/viewers/cdz_adv/downloadPDForXLS.jsp?iViewerID=1&sEntry=***that_number***&iReport=0&sPageMode=QuickDisplay&sReportMode=Viewing&iPage=1&zoom=100&isInteractive=false&iFoldPanel=0&doctype=wid&viewType=P&saveReport=N

[Sample (note it will not work it worked when the screenshot was taken):-http://dbie.rbi.org.in/AnalyticalReporting/viewers/cdz_adv/downloadPDForXLS.jsp?iViewerID=1&sEntry=we0004000048a531178c78&iReport=0&sPageMode=QuickDisplay&sReportMode=Viewing&iPage=1&zoom=100&isInteractive=false&iFoldPanel=0&doctype=wid&viewType=P&saveReport=N]

Now my question is how to access these codes without opening a real browser. And search the string and get number and accordingly get pdf download link by just doing few string manipulation?

Is it at all possible. If so please let me know. Simple solution will be much appreciated.

I'm trying in following ways now : Selenium [got suck into div selection] SAP Webi API [last resort maybe]


Solution

  • you can do it with Test tools listed below:

    1. Apache JMeter. I ever used to test our BOE platform automatically(Login BOE, click folder, open document, refresh document...). It records your operation, and repeats the operations.

    2. PhantomJS. A headless browser, not a real browser. You can write Javascript to operate the browser in background, like a human click buttons, input values...