Jump to content
Valnurat

Text felt

Recommended Posts

Valnurat

I'm trying to attach to an element in IE, but I really don't have any idea how to start. This is what I done:

 

If not WinExists("ServiceNow - Microsoft Internet Explorer") Then
    Local $oIE = _IECreate("https://service-now.com/")
    _IELoadWait($oIE)
EndIf
Sleep(10000)
if WinExists("ServiceNow - Microsoft Internet Explorer") Then
    WinActivate("ServiceNow - Microsoft Internet Explorer")
    Local $oForm = _IEFormGetObjByName($oIE, "display: inline-block;")
    Local $oText = _IEFormElementGetObjByName($oForm, "filter")
    _IEFormElementSetValue($oText, "create new")
endif

I can't see the text "create new" has been typed.

 

This is what I can see when I'm using Debugbar:

 

<form style="display: inline-block;" action="javascript:void(null);"><input title="Type filter text" align="left" id="filter" accesskey="f" type="text" placeholder="Type filter text"><a title="Clear" id="nav_filter_controls" style="visibility: visible;"><img width="16" height="16" src="images/icons/nav_clear_2.png" border="0"></a></form>

I hope someone can help me.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
water

You need to add some kind of error checking to your script. Which of the calls to _IE* returns an error?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Valnurat

I can see that _IEFormGetObjByName is returning an error.

 

--> IE.au3 T3.0-2 Warning from function _IEFormGetObjByName, $_IESTATUS_NoMatch


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Valnurat

Ok. I'm not sure what I have to look for.

<div class="nav_controls nav_filter_spacing" style="white-space: nowrap;"><div style="float: right;"><button title="Show navigator controls" class="menu-button icon-menu" id="perspective_switcher" aria-label="Show navigator controls"></button></div><div class="nav_filter_wrapper"><div class="nav_filter_container"><button class="menu-button icon icon-star-empty" id="navigator_favorite_switcher"></button><form style="display: inline-block;" action="javascript:void(null);"><input title="Type filter text" align="left" id="filter" accesskey="f" type="text" placeholder="Type filter text"><a title="Clear" id="nav_filter_controls" style="visibility: hidden;"><img width="16" height="16" src="images/icons/nav_clear_2.png" border="0"></a></form></div></div></div>

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Jfish

Not my strength but I don't see a name or id for the form so I think you may have to iterate a collection object to find the form (I am open to being corrected on that by folks that are more familiar with it).


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Danp2

A couple of suggestions for you:

  • Your script will fail if the page is already loaded in IE ($oIE never gets defined).  I would eliminate the first If...EndIf and just call _IECreate with the $TryAttach option, like this:
    Local $oIE = _IECreate("https://service-now.com/", 1)
  • You can use _IEFormGetCollection to retrieve the form object by index. If there's only one form, then this will get the object for you:

    Local $oForm = _IEFormGetCollection($oIE, 0)

     

 

Share this post


Link to post
Share on other sites
Valnurat

I tried to do this:

Local $oIE = _IECreate("https://service-now.com/", 1)
_IELoadWait($oIE)
Sleep(10000)
if WinExists("ServiceNow - Microsoft Internet Explorer") Then
    WinActivate("ServiceNow - Microsoft Internet Explorer")
    Local $oForms = _IEFormGetCollection($oIE, 0)
    Local $iNumForms = @extended
    MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & $iNumForms & " forms on this page")
    Local $oForm
    For $i = 0 To $iNumForms - 1
        $oForm = _IEFormGetCollection($oIE, $i)
        MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name)
    Next
endif

The 1st msgbox say 1

The 2nd msgbox do not show anything.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Danp2
Local $oIE = _IECreate("https://service-now.com/", 1)
_IELoadWait($oIE)

_IECreate already performs an _IELoadWait by default, so you should be able to drop the explicit one.

The 2nd msgbox do not show anything.

That makes sense because you have previously determined that the form has no name. ;-)

Share this post


Link to post
Share on other sites
Valnurat

Ok. I will delete _IELoadWait.

 

I'm just trying to find solution on what you said about Form and index.

If I do what you said:
 

Local $oForm = _IEFormGetCollection($oIE, 0)

Can you then tell me what I should do?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Valnurat

Sorry to say, but it does not work.

 

It does not fill out field with "create new"


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
water

Does any of the _IE* functions return an error?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Danp2

Sorry to say, but it does not work.

It does not fill out field with "create new"

Not very helpful response.

Does any of the _IE* functions return an error?

This is key. Run the script and post the results from the Scite output window.

Share this post


Link to post
Share on other sites
Valnurat

Right now I only have this:
 

Local $oIE = _IECreate("https://service-now.com/", 1)
if WinExists("ServiceNow - Microsoft Internet Explorer") Then
    WinActivate("ServiceNow - Microsoft Internet Explorer")
    Local $oText = _IEGetObjById($oIE, "filter")
    _IEFormElementSetValue($oText, "create new")
EndIf

This is the output in Scite output windows

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\DKSOKVK\Documents\RAD Studio\Projects\SSCreateNewIncident.au3" /UserParams    
+>13:58:11 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0   Keyboard:00000406  OS:WIN_10/  CPU:X64 OS:X64    Environment(Language:0809)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\DKSOKVK\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\DKSOKVK\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\DKSOKVK\Documents\RAD Studio\Projects\SSCreateNewIncident.au3
+>13:58:11 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\DKSOKVK\Documents\RAD Studio\Projects\SSCreateNewIncident.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
+>13:58:13 AutoIt3.exe ended.rc:0
+>13:58:13 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.417

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Jfish

I decided to go to that site in your code.  I admit I did not study the page for very long but I did not see any forms (other than search).  A search of the source code shows that search appears to be the only form.  Are you sure the form you are after is on that page? Maybe it would help if you could state specifically what field you are trying to set on that page (with words not code)? 


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
water

I couldn't find a form or an id "filter" in the source code.
You are sure we are on the correct page?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

Or do you talk about https://store.servicenow.com/$appstore.do#!/store/home where you can filter the results?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×