Sign in to follow this  
Followers 0
shahidnaz20

IE Click on Lable

10 posts in this topic




2 hours ago, genius257 said:

Look into _IEGetObjByName and _IEAction

I am new to autoit. Please quote a code.

Share this post


Link to post
Share on other sites

In the help file it shows examples for the fucntions. Do you know HTML?

; Open a browser with the "form" example, get a reference
; to the submit button by name and "click" it. This technique
; of submitting forms is useful because many forms rely on JavaScript
; code and "onClick" events on their submit button making _IEFormSubmit()
; not perform as expected

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
_IEAction($oSubmit, "click")
_IELoadWait($oIE)

And

; Same as Example 1, except instead of using click, give the element focus
; and then use ControlSend to send Enter.  Use this technique when the
; browser-side scripting associated with a click action prevents control
; from being automatically returned to your code.

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
Local $hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($oSubmit, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("", "ExampleFormSubmitted")
Sleep(2000)

ControlClick("", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
Sleep(2000)

_IEQuit($oIE)

 

Share this post


Link to post
Share on other sites
13 hours ago, crackdonalds said:

In the help file it shows examples for the fucntions. Do you know HTML?

; Open a browser with the "form" example, get a reference
; to the submit button by name and "click" it. This technique
; of submitting forms is useful because many forms rely on JavaScript
; code and "onClick" events on their submit button making _IEFormSubmit()
; not perform as expected

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
_IEAction($oSubmit, "click")
_IELoadWait($oIE)

And

; Same as Example 1, except instead of using click, give the element focus
; and then use ControlSend to send Enter.  Use this technique when the
; browser-side scripting associated with a click action prevents control
; from being automatically returned to your code.

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
Local $hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($oSubmit, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("", "ExampleFormSubmitted")
Sleep(2000)

ControlClick("", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
Sleep(2000)

_IEQuit($oIE)

 

Where to input url in these codes? Please help. I do not know HTML deeply.

Share this post


Link to post
Share on other sites
5 hours ago, shahidnaz20 said:

Where to input url in these codes? Please help. I do not know HTML deeply.

_IECreate

Share this post


Link to post
Share on other sites
On 10/16/2016 at 8:33 PM, genius257 said:

Look into _IEGetObjByName and _IEAction

#include <IE.au3>

Local $oIE = _IECreate("https://www.daraz.pk/infinix-note-3-pro-x601-16gb-3gb-champagne-gold-4g-lte-6382110.html")
_IELoadWait($oIE)
Local $oSubmit = _IEGetObjByName($oIE, "Buy Now")
_IEAction($oSubmit, "click")

 

I tried the above code. It did not work for me. Help please.

Share this post


Link to post
Share on other sites
2 minutes ago, shahidnaz20 said:

_IEGetObjByName($oIE, "Buy Now")

Buy now is the text within a label, not the name of a element...

notice the console output when debugging:

--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: Buy Now, Index: 0)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
#include <IE.au3>

Local $oIE = _IECreate("https://www.daraz.pk/infinix-note-3-pro-x601-16gb-3gb-champagne-gold-4g-lte-6382110.html")
_IELoadWait($oIE)
$o = $oIE.document.getElementsByClassName("osh-btn -primary -add-to-cart js-link js-add_cart_tracking")
$o2 = $o(0)
If $o.length>0 Then
    $o2 = $o(0)
    _IEAction($o2, "click")
EndIf

 

Share this post


Link to post
Share on other sites

Problem resolved. Thanks a lot. Nice to talk to you!!!:D

Share this post


Link to post
Share on other sites

#10 ·  Posted

4 minutes ago, genius257 said:

Buy now is the text within a label, not the name of a element...

notice the console output when debugging:

--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: Buy Now, Index: 0)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
#include <IE.au3>

Local $oIE = _IECreate("https://www.daraz.pk/infinix-note-3-pro-x601-16gb-3gb-champagne-gold-4g-lte-6382110.html")
_IELoadWait($oIE)
$o = $oIE.document.getElementsByClassName("osh-btn -primary -add-to-cart js-link js-add_cart_tracking")
$o2 = $o(0)
If $o.length>0 Then
    $o2 = $o(0)
    _IEAction($o2, "click")
EndIf

 

Problem resolved. Thanks a lot. Nice to talk to you!!!:D

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
Sign in to follow this  
Followers 0