Jump to content
oemript

How to handle error properly?

Recommended Posts

oemript
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

Share this post


Link to post
Share on other sites
Subz

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

 

Share this post


Link to post
Share on other sites
oemript
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

Share this post


Link to post
Share on other sites
oemript

There is an error on $oButton.

Do you have any suggestions on what wrong it is?

Thank you very much for suggestions (^v^)

 

Share this post


Link to post
Share on other sites
oemript
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

Share this post


Link to post
Share on other sites
oemript

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^)

 

Share this post


Link to post
Share on other sites
oemript
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Danp2

@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.

13 hours ago, oemript said:

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

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.

Share this post


Link to post
Share on other sites
Andreik

Check out ObjEvent() examples from help file.


When the words fail... music speaks

Share this post


Link to post
Share on other sites
JLogan3o13

@oemript you have been around long enough to know to keep it to one thread.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
oemript

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^)

 

Share this post


Link to post
Share on other sites
oemript
Posted (edited)
13 minutes ago, Andreik said:

Check out ObjEvent() examples from help file.

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

Share this post


Link to post
Share on other sites
oemript
Posted (edited)
On 3/6/2018 at 9: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

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

Share this post


Link to post
Share on other sites
Danp2
3 minutes ago, oemript said:

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

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

 

  • Thanks 1

Share this post


Link to post
Share on other sites
oemript
Posted (edited)
15 minutes ago, Danp2 said:
For $oButton In $oButtons
            If $oButton.InnerText = "English" Then 
                _IEAction($oButton, "click")
                ExitLoop
            EndIf
        Next

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

Share this post


Link to post
Share on other sites
Danp2
1 minute ago, oemript said:

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

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.

Share this post


Link to post
Share on other sites
oemript
Posted (edited)
6 minutes ago, 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.

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

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

×