Jump to content

SAP WEBI log on replace file IE.au3


Recommended Posts

I'm trying to create script that would login on my SAP WEBI "web page" and replace some uploaded excel files. But i'm having problem on even the log in.

These are user fill elements with Firefox Inspector

<input type="text" id="_id0:logon:CMS" name="_id0:logon:CMS">
<input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME">
<input type="password" id="_id0:logon:PASSWORD" name="_id0:logon:PASSWORD">

LogOnButton

<input type="submit" id="_id0:logon:logonButton" value="Log On" class="logonButtonNoHover logon_button_no_hover" onmouseover="this.className = 'logonButtonHover logon_button_hover';" onmouseout="this.className = 'logonButtonNoHover logon_button_no_hover';">

 

 

My example, I tried _IEGetObjByName and _IEGetObjById but the script only open page but will not even fill out the form

 
#include <IE.au3>

Call("signIn")

Func signIn()
    Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI")
    Sleep (5000)

    Local $server = _IEGetObjByName($oIE, "_id0:logon:CMS")
    Local $username = _IEGetObjByName($oIE, "_id0:logon:USERNAME")
    Local $password = _IEGetObjByName($oIE, "_id0:logon:PASSWORD")
    Local $button = _IEGetObjById($oIE, "_id0:logon:logonButton")

    _IEFormElementSetValue($server, "TestServer:1000")
    _IEFormElementSetValue($username, "MyUserName")
    _IEFormElementSetValue($password, "MyPass")

;  THIS PART ABOUT BUTTON CLICK I DONT UNDERSTAND AT ALL

    $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button"
    
    $signInUC = $oIE.document.QuerySelector($sSelector)

    _IEAction($signInUC, "click")

EndFunc   ;==>signIn

 

I would be very grateful for any help

Link to post
Share on other sites

QuerySelector is based on CSS lexical patterns. See this site for more information.

But first, lets try to understand why the form is not filled.  Do you have any frame within this page ?

Link to post
Share on other sites

I think @Nine has identified the issue. Try this modified code --

#include <IE.au3>

signIn()

Func signIn()
    Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI")
    Sleep (5000)

    Local $oFrame = _IEFrameGetObjByName($oIE, "servletBridgeIframe")
    Local $server = _IEGetObjByName($oFrame, "_id0:logon:CMS")
    Local $username = _IEGetObjByName($oFrame, "_id0:logon:USERNAME")
    Local $password = _IEGetObjByName($oFrame, "_id0:logon:PASSWORD")
    Local $button = _IEGetObjById(oFrame, "_id0:logon:logonButton")

    _IEFormElementSetValue($server, "TestServer:1000")
    _IEFormElementSetValue($username, "MyUserName")
    _IEFormElementSetValue($password, "MyPass")
    _IEAction($button, "click") 

EndFunc   ;==>signIn

If this doesn't work, then show us the results from the Scite output panel.

 

Link to post
Share on other sites
13 minutes ago, Danp2 said:

I think @Nine has identified the issue. Try this modified code --

#include <IE.au3>

signIn()

Func signIn()
    Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI")
    Sleep (5000)

    Local $oFrame = _IEFrameGetObjByName($oIE, "servletBridgeIframe")
    Local $server = _IEGetObjByName($oFrame, "_id0:logon:CMS")
    Local $username = _IEGetObjByName($oFrame, "_id0:logon:USERNAME")
    Local $password = _IEGetObjByName($oFrame, "_id0:logon:PASSWORD")
    Local $button = _IEGetObjById(oFrame, "_id0:logon:logonButton")

    _IEFormElementSetValue($server, "TestServer:1000")
    _IEFormElementSetValue($username, "MyUserName")
    _IEFormElementSetValue($password, "MyPass")
    _IEAction($button, "click") 

EndFunc   ;==>signIn

If this doesn't work, then show us the results from the Scite output panel.

 

Tnx, yes this helped, menage to log on successful .

I only change small typo

Local $button = _IEGetObjById($oFrame, "_id0:logon:logonButton")

I will now try to write rest of code...

Link to post
Share on other sites

Next step is to navigate to file and confirm... but this is too complicated for me

Click number 1

<a id="yui-gen0-1-label" tabindex="-1" class="yui-accordion-toggle" role="tab" aria-expanded="false" title="Expand My Documents">My Documents<span class="indicator" role="presentation"></span></a>
Click number 2
<a href="javascript:void(0);" class="ygtvspacer" tabindex="-1" role="presentation" aria-labelledby="ygtvcontentel8" aria-level="0">&nbsp;</a>

Click number 3

<span id="MyDocs_treeView_treeNode14_name" style="cursor:pointer; white-space:nowrap;"><img id="MyDocs_treeView_treeNodeIcon_14" src="../../../shared/pluginIconLoader/Folder/SI_PLUGIN_ICON_1.gif" style="width:16px;height:16px;" alt="Folder" border="0">&nbsp;Excel&nbsp;</span>

Click number 4

<div id="ListingURE_detailView_listColumn_6_0_1" style="overflow: hidden; padding: 2px 0px 2px 4px;" aria-describedby="ListingURE_detailView_mainTooltip">Nihad Konzum</div>

Right click on Click number 4

<a href="#" class="yuimenuitemlabel yuimenuitemlabel-selected" role="menuitem" tabindex="-1">Replace File</a>

Click Browse for path for local document, it opens windows to navigate to local PC file

<input type="file" styleid="fileUploadFileName" name="filename" size="53" class="rowInput" onchange="javascript:validateFileName();" oncontextmenu="return false;" contenteditable="false">

Click Replace for confirm

<input type="button" class="inputButton" id="replaceButton" onclick="javascript:onSubmit();" value="Replace">

 

Is possible to translate code from FireFox add on IMacros or some other macro addon.

This is from IMacros

VERSION BUILD=10021450
URL GOTO=http://192.000.000.00:0000/BOE/BI
FRAME F=4
TAG POS=1 TYPE=A ATTR=ID:yui-gen0-1-label
TAG POS=1 TYPE=A ATTR=TXT:
TAG POS=1 TYPE=SPAN ATTR=ID:MyDocs_treeView_treeNode14_name
TAG POS=1 TYPE=DIV ATTR=ID:ListingURE_detailView_listColumn_6_0_1
TAG POS=1 TYPE=A ATTR=TXT:Replace<SP>File
FRAME F=8
TAG POS=1 TYPE=INPUT:FILE FORM=NAME:uploadForm ATTR=NAME:filename CONTENT=C:\fakepath\Zaoka<SP>file.xlsx
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:replaceButton
FRAME F=1
TAG POS=1 TYPE=BUTTON ATTR=ID:yui-gen11-button

Selenium IDe

{
  "id": "7d4bedfb-f2a5-42bb-9a15-219980022696",
  "version": "2.0",
  "name": "test",
  "url": "http://192.000.000.00:000",
  "tests": [{
    "id": "04809fe1-31b7-4129-8631-b9b0fb727a87",
    "name": "test",
    "commands": [{
      "id": "92892413-697b-4961-bdaa-61e95414707d",
      "comment": "",
      "command": "open",
      "target": "/BOE/BI",
      "targets": [],
      "value": ""
    }, {
      "id": "716be288-deae-48fb-bb1a-87e8f841a341",
      "comment": "",
      "command": "setWindowSize",
      "target": "1731x819",
      "targets": [],
      "value": ""
    }, {
      "id": "2942b610-e01e-4297-a235-d9ff3091b647",
      "comment": "",
      "command": "selectFrame",
      "target": "index=0",
      "targets": [
        ["index=0"]
      ],
      "value": ""
    }, {
      "id": "436daac0-2471-4c69-8595-74286a5005fd",
      "comment": "",
      "command": "selectFrame",
      "target": "index=2",
      "targets": [
        ["index=2"]
      ],
      "value": ""
    }, {
      "id": "4d389015-331e-43f8-aa50-44a71fb2ef00",
      "comment": "",
      "command": "click",
      "target": "id=yui-gen0-1-label",
      "targets": [
        ["id=yui-gen0-1-label", "id"],
        ["linkText=My Documents", "linkText"],
        ["css=#yui-gen0-1-label", "css:finder"],
        ["xpath=//a[contains(text(),'My Documents')]", "xpath:link"],
        ["xpath=//a[@id='yui-gen0-1-label']", "xpath:attributes"],
        ["xpath=//ul[@id='yui-gen0']/li/a", "xpath:idRelative"],
        ["xpath=//a", "xpath:position"],
        ["xpath=//a[contains(.,'My Documents')]", "xpath:innerText"]
      ],
      "value": ""
    }, {
      "id": "509465eb-1e6f-4ff8-b371-b81424cbb56f",
      "comment": "",
      "command": "click",
      "target": "css=#ygtvt8 > .ygtvspacer",
      "targets": [
        ["css=#ygtvt8 > .ygtvspacer", "css:finder"],
        ["xpath=//td[@id='ygtvt8']/a", "xpath:idRelative"],
        ["xpath=//a[contains(@href, 'javascript:void(0);')]", "xpath:href"],
        ["xpath=//td/a", "xpath:position"],
        ["xpath=//a[contains(.,' ')]", "xpath:innerText"]
      ],
      "value": ""
    }, {
      "id": "357afefb-d5aa-4821-8f50-f5f7ac6a3f96",
      "comment": "",
      "command": "click",
      "target": "id=MyDocs_treeView_treeNode14_name",
      "targets": [
        ["id=MyDocs_treeView_treeNode14_name", "id"],
        ["css=#MyDocs_treeView_treeNode14_name", "css:finder"],
        ["xpath=//span[@id='MyDocs_treeView_treeNode14_name']", "xpath:attributes"],
        ["xpath=//a[@id='ygtvlabelel14']/span", "xpath:idRelative"],
        ["xpath=//div[2]/table/tbody/tr/td[3]/a/span", "xpath:position"],
        ["xpath=//span[contains(.,' Excel ')]", "xpath:innerText"]
      ],
      "value": ""
    }, {
      "id": "db98c788-a34c-4493-b51c-7adf9b8d7a72",
      "comment": "",
      "command": "click",
      "target": "id=ListingURE_detailView_listColumn_6_0_1",
      "targets": [
        ["id=ListingURE_detailView_listColumn_6_0_1", "id"],
        ["css=#ListingURE_detailView_listColumn_6_0_1", "css:finder"],
        ["xpath=//div[@id='ListingURE_detailView_listColumn_6_0_1']", "xpath:attributes"],
        ["xpath=//tr[@id='ListingURE_detailView_listNode6_0']/td[2]/div", "xpath:idRelative"],
        ["xpath=//tr[7]/td[2]/div", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "aec7d26a-dbb0-4a00-9fb0-26fae8e6dae5",
      "comment": "",
      "command": "click",
      "target": "linkText=Replace File",
      "targets": [
        ["linkText=Replace File", "linkText"],
        ["css=#yui-gen13 > .yuimenuitemlabel", "css:finder"],
        ["xpath=//a[contains(text(),'Replace File')]", "xpath:link"],
        ["xpath=//li[@id='yui-gen13']/a", "xpath:idRelative"],
        ["xpath=(//a[contains(@href, '#')])[11]", "xpath:href"],
        ["xpath=//li[5]/a", "xpath:position"],
        ["xpath=//a[contains(.,'Replace File')]", "xpath:innerText"]
      ],
      "value": ""
    }, {
      "id": "b8ad3099-7a45-4c61-8611-456e97047226",
      "comment": "",
      "command": "selectFrame",
      "target": "relative=parent",
      "targets": [
        ["relative=parent"]
      ],
      "value": ""
    }, {
      "id": "176b376b-27f3-4930-a023-7e8da8f95184",
      "comment": "",
      "command": "selectFrame",
      "target": "index=5",
      "targets": [
        ["index=5"]
      ],
      "value": ""
    }, {
      "id": "6cbe4e9f-fea0-4eb5-bf52-3c79280c072b",
      "comment": "",
      "command": "click",
      "target": "name=filename",
      "targets": [
        ["name=filename", "name"],
        ["css=.rowInput", "css:finder"],
        ["xpath=//input[@name='filename']", "xpath:attributes"],
        ["xpath=//input[16]", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "3fd5e9b0-8635-4457-88b4-dfb469def453",
      "comment": "",
      "command": "type",
      "target": "name=filename",
      "targets": [
        ["name=filename", "name"],
        ["css=.rowInput", "css:finder"],
        ["xpath=//input[@name='filename']", "xpath:attributes"],
        ["xpath=//input[16]", "xpath:position"]
      ],
      "value": "C:\\fakepath\\consume.xlsx"
    }, {
      "id": "74c3dbbc-25f8-45fc-a68b-c5a15cae4db9",
      "comment": "",
      "command": "click",
      "target": "id=replaceButton",
      "targets": [
        ["id=replaceButton", "id"],
        ["css=#replaceButton", "css:finder"],
        ["xpath=//input[@id='replaceButton']", "xpath:attributes"],
        ["xpath=//span[@id='buttonPanel']/input", "xpath:idRelative"],
        ["xpath=//span/input", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "da5037a1-fd60-4dd5-bc0a-9a29e3c634b9",
      "comment": "",
      "command": "selectFrame",
      "target": "relative=parent",
      "targets": [
        ["relative=parent"]
      ],
      "value": ""
    }, {
      "id": "392ecd1d-4dfa-4459-988d-8591552eaea6",
      "comment": "",
      "command": "click",
      "target": "id=yui-gen11-button",
      "targets": [
        ["id=yui-gen11-button", "id"],
        ["css=#yui-gen11-button", "css:finder"],
        ["xpath=//button[@id='yui-gen11-button']", "xpath:attributes"],
        ["xpath=//span[@id='yui-gen11']/span/button", "xpath:idRelative"],
        ["xpath=//button", "xpath:position"],
        ["xpath=//button[contains(.,'OK')]", "xpath:innerText"]
      ],
      "value": ""
    }]
  }],
  "suites": [{
    "id": "ea5b6a1a-a96b-4947-be97-1a54a167217a",
    "name": "Default Suite",
    "persistSession": false,
    "parallel": false,
    "timeout": 300,
    "tests": ["04809fe1-31b7-4129-8631-b9b0fb727a87"]
  }],
  "urls": ["http://192.000.000.00:000/"],
  "plugins": []
}

 

Edited by Zaoka
Link to post
Share on other sites
4 hours ago, Zaoka said:

Next step is to navigate to file and confirm... but this is too complicated for me

Yes... that is a complicated series of events.  Here are a few pointers to hopefully get you started --

  • Assuming there are still frames involved, so you will probably need switch to the correct frame first
  • Items 1, 3 & 4 all have IDs, so you should be able to use _IEGetObjById and _IEAction to perform the clicks
  • Item 2 doesn't have an ID, but maybe you can use _IELinkGetCollection with an index to obtain the desired element
  • To Right click on an element, try something like this --
    $oElement.fireEvent("oncontextmenu")

    where $oElement is the target element

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By phoenixhuynh09
      Hi everybody
      Currently I need to tick a checkbox that runs on IE. But I can't click on it. Although the correct object has been specified. Here is my code:
      #include <IE.au3> $oIE = _IEAttach("WEB") $oLinks = _IETagNameGetCollection($oIE, 'span') For $oLink In $oLinks $a = String($oLink.classname) == 'x-column-header-text' $b = StringLeft(String($oLink.id), 10) == 'gridcolumn' If $a And $b Then _IEAction($oLink, "click") ConsoleWrite("Founded" & @CRLF) ExitLoop Else ConsoleWrite("Not Found" & @CRLF) EndIf Next After inspecting the element it shows only 1 line of code:
      <div class="x-column-header x-column-header-checkbox x-column-header-align-left x-box-item x-column-header-default x-unselectable x-column-header-first x-grid-hd-checker-on" id="gridcolumn-1588" style="margin: 0px; left: 0px; top: 0px; width: 24px; right: auto; border-top-width: 1px; border-bottom-width: 1px; border-left-width: 1px;"> <div class="x-column-header-inner" id="gridcolumn-1588-titleEl"> <span class="x-column-header-text" id="gridcolumn-1588-textEl"></span> </div> </div> Here is an image of the checkbox:

      I used more ways to check:
      - _IEGetObjById => IEAction($oLink, "click") not working
      - _IETableGetCollection => _IETableWriteToArray gives an error
      - _IEImageClick
      All are not working.
      Hope to get a response from everyone.
      Thank you very much.
    • By SkysLastChance
      I am having trouble finding a good way to click these "button" below. 

      I only need to be able to click them when they have both yes/no. Otherwise I don't have to worry about them. For instance if they looked like this I would NOT have worry about clicking them and can just ignore them all togheter.(Below Picture)

      The problem is as mentioned in the title, all of the ID's  are dynamic. (Classes too)

      Here is what it looks like if yes is already selected.

      This is what I was using to select the the button. However, I need to know if the button has already been clicked/selected or not.
      _WD_LoadWait($sSession) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[text() = 'Offered access to electronic health information?']") Sleep(1000) _WD_ElementAction($sSession, $sElement, 'click') Sleep(500) _WD_Action($sSession, "actions", $sActionTab) Sleep(500) _WD_Action($sSession, "actions", $sActionEnter) Is there a way I can get the count of spans in the span class-"s_636" by tabbing over to the button? I am hoping someone might have some ideas on what I can try.
      Unfortunally, The site is for work so giving the site wont do any good. 
    • By Sachs
      I have a few questions:
      BACKGROUND
      I am using Oracle Application Testing Suite's OpenScript 13 (Eclipse IDE), Oracle Java 6, and AutoIt.
      My goal is to access a given Internet Explorer browser window (`$ieTitle`), send the keystroke of "shift-control-s" for "Save As" functionality to be invoked, so that I can download a (PDF) file to a given location ($fileName).
      The code within the script `DownloadPdfFile.au3` is
      $ieTitle = $CmdLine[1] $ieControl = "AVL_AVView31" $fileName = $CmdLine[2] ControlFocus($ieTitle, "", $ieControl) ControlSend($ieTitle, "", $ieControl, "+^s") ; Save as dialog $winTitle = "Save As" ; wait for Save As window WinWait($winTitle) ; activate Save As window If Not WinActive($winTitle) Then WinActivate($winTitle) ControlFocus($winTitle,"","Edit1") ControlSetText($winTitle,"","Edit1",$fileName) Sleep(2000) ControlClick($winTitle,"","Button3") Exit 0 So I compiled it with SciTE-Lite (32-bit Version 4.4.6 , creating `DownloadPdfFile.exe`, and so within my Java code, I have
      String command = autoItExePath + " " + scriptPath + " \"" + winTitle + "\" " + directoryPath.toFile().toString() + "\\Form9Report" + sdf_ddmmmyyyy.format(new Date()) + ".pdf"; try { Process process = Runtime.getRuntime().exec(command); process.waitFor(); } catch (Exception e) { logger.error("Exception " + e.getMessage(), e); } The output would be like `C:\Program Files (x86)\AutoIt3\AutoIt3.exe C:\...\AutoItScripts\DownloadPdfFile.au3 "https://****.com/****.exe?temp_id=**** - Internet Explorer" C:\...\Report05Apr2022.pdf"` which does run without the $cmdLine successfully. 
      When executed by Java, I see in the taskbar an icon, which I right-click has "[Check] Script Paused" and "Exit".
      Questions:
      (1) How do I unpause the script?
      (2) How do I avoid having the script paused?
      Any help is appreciated.
    • By goku200
      I'm having an issue with my html paginated table. The script work as expected. It reads the html table and clicks on the Download button. However when it clicks on the next page its not iterating the items. instead it goes to the next URL from the spreadsheet and then iterates through the html table clicking the Download button and so on. Not sure why its doing that. I want it to click the next page and then continue iterating then after it has reached the end of the pagination go to the next url in the spreadsheet and repeat the process. Below is my script. Any help is appreciated 🙂
       
       
    • By Steviep
      Hi all,
      I've been using the following code for many years for the sole purpose of tracking my app usage via Google Analytics:
      ;GOOGLE ANALYTICS $AppStatsName = @ScriptName $GA = _IECreate("https://mywebserver/apps/stats/" & $AppStatsName & ".html", 0, 0, 0, 0) The app simply calls a blank .html page on my webserver which only contains the GA tracking code.
      The $iVisible parameter is set to "0" in my case, which means the IE browser is invisible to the user.
      I noticed in Windows 11, the URL is called in the Edge browser and is not invisible.
      So, I wonder if anyone out there has any suggestions on calling a URL invisibly on any operating system?
      Thanks!
×
×
  • Create New...