shahidnaz20 Posted October 16, 2016 Posted October 16, 2016 Dear All I want to click on "BUY NOW" on the following link using autoit script. https://www.daraz.pk/infinix-note-3-pro-x601-16gb-3gb-champagne-gold-4g-lte-6382110.html Please help
genius257 Posted October 16, 2016 Posted October 16, 2016 Look into _IEGetObjByName and _IEAction shahidnaz20 1 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
shahidnaz20 Posted October 16, 2016 Author Posted October 16, 2016 2 hours ago, genius257 said: Look into _IEGetObjByName and _IEAction I am new to autoit. Please quote a code.
crackdonalds Posted October 16, 2016 Posted October 16, 2016 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)
shahidnaz20 Posted October 17, 2016 Author Posted October 17, 2016 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.
genius257 Posted October 17, 2016 Posted October 17, 2016 5 hours ago, shahidnaz20 said: Where to input url in these codes? Please help. I do not know HTML deeply. _IECreate To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
shahidnaz20 Posted October 17, 2016 Author Posted October 17, 2016 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.
genius257 Posted October 17, 2016 Posted October 17, 2016 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 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
shahidnaz20 Posted October 17, 2016 Author Posted October 17, 2016 Problem resolved. Thanks a lot. Nice to talk to you!!!
shahidnaz20 Posted October 17, 2016 Author Posted October 17, 2016 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!!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now