Jump to content

Click on object (IE)


elads
 Share

Recommended Posts

Hey,

I would like to click on a button after i'm logged to my system (web).

Here's the scenrario:

$oIE = _IECreate("http://www.somesite.com")

$oform = _IEFormGetObjByName($oIE, "start-login-form")
$ologin = _IEFormElementGetObjByName($oform, "Email") ; Email
$opassword = _IEFormElementGetObjByName($oform, "Passwd") ; Passwd

_IEFormElementSetValue($ologin, $sUsername)
_IEFormElementSetValue($opassword, $sPassword)
_IEFormSubmit($oform)

So far so good...

Now after i've logged in, I want to click on a button/link on that page.

What's the right command and how do i use it?

Thanks

Edited by elads
Link to comment
Share on other sites

Hey,

I would like to click on a button after i'm logged to my system (web).

Here's the scenrario:

$oIE = _IECreate("http://www.somesite.com")

$oform = _IEFormGetObjByName($oIE, "start-login-form")
$ologin = _IEFormElementGetObjByName($oform, "Email") ; Email
$opassword = _IEFormElementGetObjByName($oform, "Passwd") ; Passwd

_IEFormElementSetValue($ologin, $sUsername)
_IEFormElementSetValue($opassword, $sPassword)
_IEFormSubmit($oform)

So far so good...

Now after i've logged in, I want to click on a button/link on that page.

What's the right command and how do i use it?

Thanks

After you read the help file (You did read the help file, right?), and you tried the example scripts for the _IE* functions (You did try the examples, right?), what did you finally test and how it turn out?

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

After you read the help file (You did read the help file, right?), and you tried the example scripts for the _IE* functions (You did try the examples, right?), what did you finally test and how it turn out?

:D

Yes I did...

tried this right after:

_IEGetObjByName ($oButton, "button I want to click on")
_IEAction ($oButton, "click")

"button I want to click on" is a button that appears in that web page that opens, and that's what I want to click on...

As for the outcome, the page opens ok and the sign-in part is good. but after that nothing happens

Edited by elads
Link to comment
Share on other sites

I don't think the part that you think you have problems with is actually the problem. It's more like that a few lines of code just before it are causing trouble.

These two functions: _IEGetObjByName and _IEAction are almost instant. There is no waiting inside, or anything.

Let me demonstrate by giving some bad input into them:

#include <IE.au3>

$oButton = "NOT AN OBJECT"

_IEGetObjByName ($oButton, "button I want to click on")
_IEAction ($oButton, "click")

Result:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Jos\Desktop\lol.au3"    
--> IE.au3 V2.4-0 Error from function _IEGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType
>Exit code: 0    Time: 0.209
Edited by Manadar
Link to comment
Share on other sites

Yes I did...

tried this right after:

_IEGetObjByName ($oButton, "button I want to click on")
_IEAction ($oButton, "click")

"button I want to click on" is a button that appears in that web page that opens, and that's what I want to click on...

As for the outcome, the page opens ok and the sign-in part is good. but after that nothing happens

Look again at _IEGetObjbyName() in the help file. The first parameter is $oIE or $oForm, etc., the PARENT object that has the one you are looking for under it. The second parameter is the button name (or ID, which is more reliable) in the HTML. So that should look more like:
$oButton = _IEGetObjByName($oIE, "ButtonName")
_IEAction($oButton, "click")

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 8 years later...

I too have this problem but not with the button.

I am trying to click inputbox.

$IE = _IEAttach($AssemblyWindow)
$PageLoadDone = _IELoadWait($IE)
$IEObject = _IEGetObjByname($IE, "txtSearch")
_IEAction($IEObject, "click")

Nothing happens unless i click it with mouse.

It ONLY works for buttons but not for a=inputs and combo boxes.
Maybe inputs and combos i try to click are none standard ?

 

<INPUT onkeypress=ValidationForCatalogandInventoryText();CheckScan(); onkeyup=EnableSearchButton(); onfocus=RemoveScanText(this.id); onblur=SystemSettingsTrim();SetScanText(false); id=txtSearch class=textbox onpaste=EnableSearchButton();OnPasteDisallowSpecialChars(); style="BACKGROUND-COLOR: white" ondrop="OnDragDropDisallowSpecialChars('btnSearch');" maxLength=15 value="Scan an item ..." name=txtSearch>

Thats where i want to click.

Edited by tonycst
Link to comment
Share on other sites

8 years yet i landed here when i was searching for answers.
I think its best to keep adding to the thread VS creating new once containing same information over and over and over again, cluttering sql database.

 

But what do i know.

Ill do what you say.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...