Jump to content

Recommended Posts

Posted (edited)

Please see following image,  there is a language selection before entering web page, I would like to know on how to code on clicking English as shown below

https://shopee.com.my/

Shop1.png

Does anyone have any suggestions?
Thanks in advance for any suggestions

 

 

Edited by oemript
Posted

Try:

#include <IE.au3>
Local $oButtons
Local $oIE = _IECreate("https://shopee.com.my/", 1)
Sleep(5000)
Local $oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "language-selection__list" Then
        $oButtons = _IETagNameGetCollection($oDiv, "button")
        For $oButton In $oButtons
            If $oButton.InnerText = "English" Then _IEAction($oButton, "click")
        Next
    EndIf
Next

 

Posted (edited)

Please see following image,  there is an error as shown below

Shop3.png

Do you have any suggestions on what wrong it is?

Thank you very much for suggestions (^v^)

Edited by oemript
Posted

There is an error on $oButton.

Do you have any suggestions on what wrong it is?

Thank you very much for suggestions (^v^)

 

Posted (edited)

Please see following image,  I still get an error with lower case as shown below

Shop4.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

Edited by oemript
Posted

For _IEPropertyGet under Help, there is no browser properties for "click" action.

Do you have any suggestions on how _IEPropertyGet works for clicking button?
Thanks, to everyone very much for any suggestions (^v^)

 

Posted (edited)

Please see following image, would it be possible to handle the error? so the rest of coding can able to run as shown below:

Instead of solving the error on button, I prefer to skip this error properly, so the rest of coding can be run.

Shop5.png

Does anyone have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

Edited by oemript
Posted (edited)

Referring to following image, there is an error on Button's issue, and I would like to know on how handle and skip this error (not solve the error, since I get no idea, if someone gets an idea on solving it, then it would be great), and keep the rest of codes running, such as show MsgBox in this case.

Shop5.png

Does anyone have any suggestions?
Thanks in advance for any suggestions

 

==========================================================================

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <IE.au3>
; Create a constant variable in Local scope of the filepath that will be read/written to.
; Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir

Local $oButtons
Local $oIE = _IECreate("https://shopee.com.my/", 1)
Sleep(5000)
Local $oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "language-selection__list" Then
        $oButtons = _IETagNameGetCollection($oDiv, "button")
        For $oButton In $oButtons
            If $oButton.innerText = "English" Then _IEAction($oButton, "click")
        Next
   EndIf
Next
MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10)

 

Edited by oemript
Posted

@oemript You keep asking the same thing over and over without showing any effort in solving the problem yourself. That isn't how this forum works. Were here to assist and point you in the right direction, but the expectation is that you take this information and use it to solve the problem on your own.

  On 3/6/2018 at 11:41 PM, oemript said:

For _IEPropertyGet under Help, there is no browser properties for "click" action.

Expand  

That's correct. You can't click using _IEPropertyGet. However, if you look in the help file, you will see that it can be used to retrieve the innertext of the designated control. Since this is the area where your script was failing, I suggested that you switch to _IEPropertyGet.

Posted

This post is to handle and skip error, and the other post is to click the Button,

Both post are on different issue, would it be OK?

Thanks, to everyone very much for any suggestions (^v^)

 

Posted (edited)
  On 3/7/2018 at 1:28 PM, Andreik said:

Check out ObjEvent() examples from help file.

Expand  

Please see following image, I would like to know on how ObjEvent help on issues related to innerText or Clicking button.

ObjEvent.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

Edited by oemript
Posted (edited)
  On 3/6/2018 at 1:30 AM, Subz said:

Try:

#include <IE.au3>
Local $oButtons
Local $oIE = _IECreate("https://shopee.com.my/", 1)
Sleep(5000)
Local $oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "language-selection__list" Then
        $oButtons = _IETagNameGetCollection($oDiv, "button")
        For $oButton In $oButtons
            If $oButton.InnerText = "English" Then _IEAction($oButton, "click")
        Next
    EndIf
Next
Expand  

Please see following image, I tried, and the button is clicked successfully, but there is an error, this error stops running the rest of coding such as MsgBox as shown below, that is the error issues.

Shop5.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

Edited by oemript
Posted
  On 3/7/2018 at 1:48 PM, oemript said:

Please see following image, I tried, and the button is clicked, but there is an error

Expand  

Are you sure the button is being clicked? I'm thinking not.

However, you could rewrite that section of code like this, so that it stops looping after the correct button is found --

For $oButton In $oButtons
            If $oButton.InnerText = "English" Then 
                _IEAction($oButton, "click")
                ExitLoop
            EndIf
        Next

 

Posted (edited)
  On 3/7/2018 at 1:54 PM, Danp2 said:
For $oButton In $oButtons
            If $oButton.InnerText = "English" Then 
                _IEAction($oButton, "click")
                ExitLoop
            EndIf
        Next
Expand  

Yes, the language selection list is disappeared, and error occurs as shown below

Shop7.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

Edited by oemript
Posted
  On 3/7/2018 at 2:09 PM, oemript said:

Yes, the language selection list is disappeared, and error occurs as shown below

Expand  

The issue is that you have a collection of button objects that you are traversing. Once you click on a button, the buttons no longer exist, yet you continue to process the collection.

Change the code like I indicated above and the error should disappear.

Posted (edited)
  On 3/7/2018 at 2:11 PM, Danp2 said:

The issue is that you have a collection of button objects that you are traversing. Once you click on a button, the buttons no longer exist, yet you continue to process the collection.

Change the code like I indicated above and the error should disappear.

Expand  

I get it, there are 2 loops,

1) ExitLoop only exit for "For $oButton In $oButtons",

2) How to exit "For $oDiv In $oDivs" as well if only if "$oButton.InnerText = "English" . 

There are 2 loop needed to exit here.

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

Edited by oemript

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.
×
×
  • Create New...