ss26

[Solved] Cannot click div (IE.au3)

14 posts in this topic

#1 ·  Posted (edited)

G'Day,

Faced a problem with interacting with page elements through IE UDF.

Here is HTML code of element i want to click (div styled as button):

<div id="group_actions_btn" class="group_actions_btn" onmousedown="Groups.actionsDropdown(this);">
    <span class="group_actions_btn_text">Button text</span>
</div>

I tried some code to click it, but it doesn't work:

1)

Local $group_actions_btn = _IEGetObjById($oIE, "group_actions_btn")
_IEAction($group_actions_btn, "focus")
_IEAction($group_actions_btn, "click")

2) [modified code from some more or less relevant forum post]

$divs = $oIE.document.getElementsByClassName("group_actions_btn")
For $div In $divs
$div.click()
Next

3) [same as 2) but from another thread]

$oDivs = _IETagNameGetCollection ($oIE, "div")
 For $oDiv In $oDivs
    If $oDiv.id = "group_actions_btn" Then _IEAction($oDiv, "click")
 Next

 

What am i doing wrong? Thanks

Edited by ss26

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

 

Local $oElements = _IETagNameGetCollection($oIE, "div")

For $oElement In $oElements

   if $oElement.classname=="group_actions_btn" then

     _IEAction ($oElement, "click")
     
   EndIf
;ConsoleWrite ( $oElement.classname & @CRLF)
 next

 

 

Try this way. If it wont work, you should understand whether it is finding the elements at all. To do that you should uncomment line with consolewrite and in your console you will see the elements which are found, then try to click those found elements instead of "group_actions_btn"

Edited by topten
1 person likes this

Share this post


Link to post
Share on other sites

 

​Thanks, i tried, but unfortunately it doesn't worked out either. Now i need to learn how get result from ConsoleWrite and then will look at that output.

Share this post


Link to post
Share on other sites

Output of ConsoleWrite is following:

fixed






chat_onl_wrap
chats_sp chat_cont_sh_top
chat_cont_scrolling
chat_onl_height
chats_sp chat_cont_sh_bottom
chat_onl_cont
chat_onl
chats_sp chat_onl_icon

fixed
scroll_fix_wrap fixed

fixed
scroll_fix_wrap fixed


loader
back
fixed

fixed

fixed
rb_box_wrap fixed fc_fixed rb_inactive fc_tobottom
fc_tab_wrap
fc_tab_head
chats_sp fc_tab_close
chats_sp fc_tab_pin
fc_tab_title noselect

fc_ctab fc_ctab_active
fc_contacts_wrap
fc_scrollbar_cont
fc_scrollbar_inner
fc_contacts
fc_clist_filter_wrap
chats_sp fc_clist_search_icon
fc_clist_online_wrap fl_r
fc_clist_online
fc_clist_filter
input_back_wrap no_select
input_back
input_back_content
fc_pointer_offset
chats_sp fc_tab_pointer
scroll_fix_wrap

scroll_fix

p_head p_head_l0
back
left
right
content
head_nav


clear_fix
ts_input_wrap fl_r
ts
ts_input_wrap2

input_back_wrap no_select
input_back
input_back_content

fl_l
more_div



ads_ads_box ver repeat_ver size_site
ads_ads_box2 ver repeat_ver size_site
ads_ads_box3 ver repeat_ver size_site
ads_ads_box4 ver repeat_ver size_site
ads_ad_box ver repeat_ver size_site first
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver first
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver first
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver promotion
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ad_box ver repeat_ver size_site
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ad_box ver repeat_ver size_site last
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver last
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver last
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver promotion
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ads_all_ads
fl_r









narrow_column fl_r



owner_photo_bubble_delete_wrap
owner_photo_bubble_delete



owner_photo_bubble_action owner_photo_bubble_action_update
owner_photo_bubble_action owner_photo_bubble_action_crop
page_actions
separator

unshown
group_actions_header
group_actions_inner
progress fl_r
group_actions_btn
group_like_desc_wrap 
module clear people_module
header_top clear_fix
p_header_bottom
module_body clear_fix
people_row
fl_l people_cell
name_field
module clear groups_list_module empty
header_top clear_fix
module_body clear_fix

module clear page_list_module
header_top clear_fix
p_header_bottom
module_body clear_fix
fl_l thumb
fl_l info
wide_column fl_l
top_header page_name
clear


clear

editor
fl_l checkbox unshown

fl_l checkbox unshown

clear



group_info
clear_fix 
label fl_l
labeled fl_l

module clear photos_module empty
header_top clear_fix
module_body clear_fix
wall_module
module_header wall_header
clear_fix
error
clear_fix
input_back_wrap no_select
input_back
input_back_content


clear_fix multi_media_preview
page_pics_preview media_preview clear_fix
page_pics_preview page_media_sortable media_preview clear_fix
page_docs_preview page_media_sortable media_preview clear_fix
page_docs_preview media_preview clear_fix
page_docs_preview media_preview clear_fix
page_pics_preview media_preview clear_fix
page_docs_preview media_preview clear_fix
page_progress_preview media_preview clear_fix
checkbox fl_l 

fl_r
progress fl_r

clear_fix
all

progress

fl_r

clear
copy_lang

clear

scroll_fix

add_media_menu 
add_media_rows
rows
add_media_items
add_media_head noselect
add_media_more_wrap
add_media_more_node
unshown
progress

So many stuff... Will try to click parent elements brought by ConsoleWrite.

Also checked HTML source of page, and mentioned class is there only for that button.

Share this post


Link to post
Share on other sites

Alas, still can't make it click that button.

Share this post


Link to post
Share on other sites

Just to make the things a little easier, can you  analyze the elment which you want to click with firebug (it is addon to firefox) or if you dont have one, navigate the website in firefox, then move your mouse coursor to the element then right click,  "research element" - thus you will see which elements are involved. Sometimes in such situation you should use not "div", but "a"  or "p", then repeat analyzing with console write untill you find the element to click

Share this post


Link to post
Share on other sites

Btw I have just again looked through the list which you get by console write and I see there "group_actions_btn" - it means that it is finding the element but not clicking on it (?)- or, when you are clicking the button- you are not clicking actually "group_actions_btn" but something else. I would advise you to check again with firebug and check again what is it clicking there?

I met such situations many times before- when you think that you are dealing with this element, but in fact- the action is firing some neighbouring element

 

fixed






chat_onl_wrap
chats_sp chat_cont_sh_top
chat_cont_scrolling
chat_onl_height
chats_sp chat_cont_sh_bottom
chat_onl_cont
chat_onl
chats_sp chat_onl_icon

fixed
scroll_fix_wrap fixed

fixed
scroll_fix_wrap fixed


loader
back
fixed

fixed

fixed
rb_box_wrap fixed fc_fixed rb_inactive fc_tobottom
fc_tab_wrap
fc_tab_head
chats_sp fc_tab_close
chats_sp fc_tab_pin
fc_tab_title noselect

fc_ctab fc_ctab_active
fc_contacts_wrap
fc_scrollbar_cont
fc_scrollbar_inner
fc_contacts
fc_clist_filter_wrap
chats_sp fc_clist_search_icon
fc_clist_online_wrap fl_r
fc_clist_online
fc_clist_filter
input_back_wrap no_select
input_back
input_back_content
fc_pointer_offset
chats_sp fc_tab_pointer
scroll_fix_wrap

scroll_fix

p_head p_head_l0
back
left
right
content
head_nav


clear_fix
ts_input_wrap fl_r
ts
ts_input_wrap2

input_back_wrap no_select
input_back
input_back_content

fl_l
more_div



ads_ads_box ver repeat_ver size_site
ads_ads_box2 ver repeat_ver size_site
ads_ads_box3 ver repeat_ver size_site
ads_ads_box4 ver repeat_ver size_site
ads_ad_box ver repeat_ver size_site first
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver first
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver first
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver promotion
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ad_box ver repeat_ver size_site
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ad_box ver repeat_ver size_site last
left_hide_button
ads_ad_close_info
ads_ad_box_border repeat_ver last
ads_ad_close_info2
ads_ad_close_info3
ads_ad_close_info4
ads_ad_close_text
ads_ad_close_complain
ads_ad_box_border repeat_ver last
ads_ad_box3 ver
ads_ad_box4 ver
ads_ad_box5 ver repeat_ver
ads_ad_box5_spacer ver repeat_ver size_site
ads_ad_box6 ver
ads_ad_text_box ver repeat_ver size_site
ads_ad_title_box ver repeat_ver
ads_ad_title_spacer1 ver repeat_ver
ads_ad_title_spacer2 ver repeat_ver
ads_ad_title ver repeat_ver
ads_ad_domain ver
ads_ad_photo_box ver promotion
ads_ad_play ver unshown empty
ads_ad_play_app
ads_ad_disclaimers_photo
ads_ad_description ver
ads_ad_community_join
ads_ad_disclaimers_bottom
ads_ads_all_ads
fl_r









narrow_column fl_r



owner_photo_bubble_delete_wrap
owner_photo_bubble_delete



owner_photo_bubble_action owner_photo_bubble_action_update
owner_photo_bubble_action owner_photo_bubble_action_crop
page_actions
separator

unshown
group_actions_header
group_actions_inner
progress fl_r
group_actions_btn
group_like_desc_wrap 
module clear people_module
header_top clear_fix
p_header_bottom
module_body clear_fix
people_row
fl_l people_cell
name_field
module clear groups_list_module empty
header_top clear_fix
module_body clear_fix

module clear page_list_module
header_top clear_fix
p_header_bottom
module_body clear_fix
fl_l thumb
fl_l info
wide_column fl_l
top_header page_name
clear


clear

editor
fl_l checkbox unshown

fl_l checkbox unshown

clear



group_info
clear_fix 
label fl_l
labeled fl_l

module clear photos_module empty
header_top clear_fix
module_body clear_fix
wall_module
module_header wall_header
clear_fix
error
clear_fix
input_back_wrap no_select
input_back
input_back_content


clear_fix multi_media_preview
page_pics_preview media_preview clear_fix
page_pics_preview page_media_sortable media_preview clear_fix
page_docs_preview page_media_sortable media_preview clear_fix
page_docs_preview media_preview clear_fix
page_docs_preview media_preview clear_fix
page_pics_preview media_preview clear_fix
page_docs_preview media_preview clear_fix
page_progress_preview media_preview clear_fix
checkbox fl_l 

fl_r
progress fl_r

clear_fix
all

progress

fl_r

clear
copy_lang

clear

scroll_fix

add_media_menu 
add_media_rows
rows
add_media_items
add_media_head noselect
add_media_more_wrap
add_media_more_node
unshown
progress

 

Share this post


Link to post
Share on other sites

I would advise you to check again with firebug and check again what is it clicking there?

I met such situations many times before- when you think that you are dealing with this element, but in fact- the action is firing some neighbouring element

 

​How to find out what is it clicking there? When action (click) is done script is paused by msgbox after some seconds (for me to see if something was changed on page), but none changes detected (visually).

Checked with Firebug all neighbouring elements, but:

1) none has same id/class (that's strange because i also thought that something may spoil detection of correct element, but it has unique id AND class)

2) no other elements to click except parent DIV container, which appeared to make no sense to click (nevertheless i also tried to click it), and inner span with text. No success on trying to click any of these.

Besides, DIV from first post is the only element which has relevant JS action attached (onmousedowm). No other links and JS "action" events etc.

P.S.: example page can be any VK.com group like this https://vk.com/club92594181 , but to see button user should bу logged in and should have joined a "group" (button: http://take.ms/Agl7W  and firebug: http://take.ms/vZDB4 )

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

;)

It is funny to see how such sites as vk are trying to limit its automatisation for coders.

so what happens there? In fact programmatically the button is clicked but as it sees there is no mouse over there it just immediately hides the dropdown. So- you think that you cant click it, but in fact you have clicked it- just it doesnt show up- because your mouse is not over....

The question is: Why do you want to click that button? May be because it will show you the drop down with some menu such as "пригласить друзей" :)?

Am I right?

n2ga61.jpg

 

And then you wanna click that button?

 

_IENavigate($oIE, "https://vk.com/club92594181")
_IELoadWait($oIE)
 Local $oElements = _IETagNameGetCollection($oIE, "a")

For $oElement In $oElements

   if $oElement.classname=="group_actions_item" then

      _IEAction ($oElement, "click")
   EndIf
;ConsoleWrite ( $oElement.classname & @CRLF)
   next

And voila....

ilg095.jpg

 

Edited by topten
1 person likes this

Share this post


Link to post
Share on other sites

Thanks a lot for discovering "hidden logic" behind elements interaction there! (I could spend ages on this with my attempts)

That's almost what i want, except i need to click last button ("Выйти из группы": http://take.ms/8HL5s ). Seems U R right about vk trying to limit its automatisation - even those items with "group_action_item" class have blank ids.

Now i will try to find out how to click desired item (suppose something to do with link index, i guess i met something relevant in docs or here, on forums).

 

Share this post


Link to post
Share on other sites

:ILA2:  You are right there are 3 "group_actions_item" elements. And we need to click on the third one.

So we start to calculate the elements with a simple addon to our function and when we come to the third one, click on it

Local $oElements = _IETagNameGetCollection($oIE, "a")
$i = 0
For $oElement In $oElements

   if $oElement.classname=="group_actions_item" then
   $i = $i+1
   if ($i==3) then
     
      _IEAction ($oElement, "click")
   endif
    
   EndIf
ConsoleWrite ( $oElement.classname & @CRLF)
   next

Thats it

1 person likes this

Share this post


Link to post
Share on other sites

Thanks very much! I just tried my ugly code to make it click third link with this class (with no positive result yet), but you already posted working code :)

Share this post


Link to post
Share on other sites

Great! Lets mark the topic as solved then!

Share this post


Link to post
Share on other sites

Done :)

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