Jump to content
Zaoka

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

Share this post


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 ?

Share this post


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.

 

Share this post


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...

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


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

Share this post


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 devilspride
      The following code creates a IE blank window
      Local $oIE = _IECreate()  
      But when i use Navigate to the URL, it open the URL in Microsoft Edge instead if IE.
      _IENavigate($oIE,$url)  
      What should i do to navigate in IE.
      Complete code :
      #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <IE.au3> #Region TESTING Local $url = 'https://www.youtube.com' Local $oIE = _IECreate() _IENavigate($oIE,$url) #EndRegion Console Output
      IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)  
      I have searched the forums but did not find such kind of post.
      Other posts were describing How to use Edge using Web driver selenium.
       
      Edit: I am working in Windows10. Recently many changes have been done by Microsoft to IE and Microsoft Edge. (2020)
      Earlier in 2019 this was working fine.
    • By amosrinat
      Hi,
      i have an AutoIT script that sends emails with two embedded images.
      When users get the email they don't see the images. How should I fix my code?
      Thank you for your support,
      Amos
      Func fSendMail() $TemplateName = StringRegExpReplace($Template, "^.*\\|\..*$", "") $SmtpServer = "smtp.**.com" $FromName = "do-not-reply@*********" $FromAddress = "do-not-reply@******" $ToAddress = $MG1_Mgr & ";"& $Owner $Subject = "ACTION REQUIRED - " & $TemplateName $Body = $sBody5 $IPPort = 25 $ssl = 0 Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = fINetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $IPPort, $ssl) If @error Then MyErrFunc() EndIf EndFunc;fSendMail Func fINetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort $objEmail.Configuration.Fields.Update $objEmail.Fields.Update ;$objEmail.Send **************** If @error Then MyErrFunc() EndIf $objEmail = "" EndFunc;fINetSmtpMailCom  
    • By Colduction
      Hi guys, i'm using Telegram UDF by @LinkOut from github with latest update, but this UDF has not any parse_mode ability in SendDocument and other send file's functions to make texts bold, italic or underline and i can't send Emojis via these functions too. i've tried to change HTML section of multipart/form-data but i did not get correct results.

      For example, i can't get correct results by sending a document with this URL Encoded caption: %F0%9F%93%84%20*Test*%20%F0%9F%93%84

      I will be happy to help me in this section. Thanks!
    • By adityaparakh
      Hello ,

      A website I am trying to login with my credentials.
      And retrieve the cookie into a text file.
      Unable to do so.
      Is it that certain,  Httponly , type - are not allowed to be fetched.

      Then further ,
      I will be checking every 5 minutes if my session is active , else re-login and re-fetch the cookie.
      For the second part , I will probably fetch some table and see if not in appropriate format do Part 1 : Fetch Cookie - again.
      Any better way , tips would be appreciated.
       
      Thanks
       
    • By Jamestay97
      Hello! Thanks you for looking at my post
      **No source code I'm sorry work related can't copy information**
      I've been using autoit for about 1 year. 
      I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling. 
      Description of object I'm trying to click -- 
      HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow. 
       
      I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions. 
×
×
  • Create New...