Jump to content

Recommended Posts

Posted

Hello guys,


I want your advise here. I have a select2 dropdown menu that have to make automation on. I have tried with:

;$jQuery('#s2id_company_id').select2("val", "16013").trigger('change.select2');

but it is not working correctly... It is selecting the value, but there is something like AJAX that is making changes after selecting something from the dropdown, Example:

 

image.png.cf69fb678496410cc34adb3436248445.png

 

after:

Automatically changed:

 

image.png.1147f2eb708e98b22a0482d3e7192d30.png

 

You can see the html of it below:

 

image.thumb.png.fc8879e8d8e0ac57d52cccc1bab30cae.png

 

Currently in order to work I am doing the following:

 

$jQuery('#s2id_company_id').select2('search', $CompanyName)         ; Search by Company
        Sleep(2000)
        _ClickSearchedValueSelect2()
        Sleep(1500
        
        
        
        
    Func _ClickSearchedValueSelect2()

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{ENTER}")

    Sleep(1500)

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{TAB}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{TAB}")

EndFunc   ;==>_ClickSearchedValueSelect2

 

The above is working, but when the automation using the ControlSend is working, who is using it will not be 100% able to work on the PC because the focus from the windows they will be working on will be taken in some point.

Can someone advise how is the best way of doing the select2 item selection with triggering the changes after it ?

 

Thank you guys,

 

Milen

 

Posted

I have another question, as most likely because there is minimum characters to input  before the list is viewed:

image.png.7fb412185c597f2247b9ca39bb41d9a2.png

I am not able to change some values with the above. Could you please advise of a workaround ?

 

Posted

The dropdown I have issues with is exactly like this one:
image.png.f9392f5c4067f4f36640742746cce2c1.png

 

but unfortunately I cannot reproduce the issue from the website you provided, because the script just hang when try to.

What I use now is 

$jQuery('#s2id_company_id').select2('search', $CompanyName)         ; Search by Company
        Sleep(2000)
        _ClickSearchedValueSelect2()
        Sleep(1500
        
        
        
        
    Func _ClickSearchedValueSelect2()

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{ENTER}")

    Sleep(1500)

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{TAB}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{TAB}")

EndFunc   ;==>_ClickSearchedValueSelect2

and it is working, but I want to start doing it the way you suggested:

 

$jQuery('#s2id_company_id').select2("val", "16013", "triggerChange", true)

which is working for the fields without minimumInputLength

Thank you again for your assistance, much appreciated!

 

Posted

Hi again @Danp2,

 

I have reproduced it form the site you gave me, you can see the example code below:

 

#include <IE.au3>


Global $oIE = _IEAttach("http://select2.github.io/select2/", "url")

Local $jQuery = _jQuerify($oIE)

$jQuery('#s2id_e3').select2("val", "Alaska", "triggerChange", true)

 

The above code is working, it is changing the value to Alaska, when it is something else, for example Oregon. But, when it is Alaska, I cannot change ti to anything else.

 

#include <IE.au3>


Global $oIE = _IEAttach("http://select2.github.io/select2/", "url")

Local $jQuery = _jQuerify($oIE)

$jQuery('#s2id_e3').select2("val", "Oregon", "triggerChange", true)

The above is not changing to Oregon when it is on something else, Alaska for example.

 

Maybe there is some other way to work with this kind of select2 fields with minimumInputLength  set, I hope you will advise me what to do :)

Thank you,

Milen

 

Posted

You are using the wrong values. Try this --

#include <IE.au3>

Global $oIE = _IECreate("http://select2.github.io/select2/", 1)
Local $jQuery = _jQuerify($oIE)

$jQuery('#s2id_e3').select2("val", "OR", "triggerChange", true)
Sleep(1000)
$jQuery('#s2id_e3').select2("val", "FL", "triggerChange", true)
Sleep(1000)
$jQuery('#s2id_e3').select2("val", "TN", "triggerChange", true)

 

  • 2 weeks later...
Posted

Hi @Danp2,

 

I have asked the website admins about the select2 dropdowns I have issues with, and they told me that:

 

Quote

Is because the second one uses a dynamic search (where the results are fetched from the server based on user input), whereas the first one has all the results preloaded (which is why it's so slow). So you can manually change the value of the pre-loaded version but not the dynamic load version which requires "searching".

 

 

My question to them was why on some of their select2 dropdowns I can directly select with

$('#s2id_e3').select2("val", "Alaska", "triggerChange", true)

but on another I can't and as a workaround I am using 

 

$jQuery('#s2id_company_id').select2('search', $CompanyName)         ; Search by Company
        Sleep(2000)
        _ClickSearchedValueSelect2()
        Sleep(1500
        
        
        
        
    Func _ClickSearchedValueSelect2()

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{ENTER}")

    Sleep(1500)

    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{TAB}")
    ControlSend("Terminal", "", "[CLASS:Internet Explorer_Server; INSTANCE:9]", "{TAB}")

EndFunc   ;==>_ClickSearchedValueSelect2

 

@Danp2, as you have a lot of experience with similar things, can you please advise me if really there is a better way of selecting the values when they are fetched from the server based on user input.

 

Thank you,

Milen

 

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