How do I click on this button(javascript) on webbrowser?

matty95srk

Member
Joined
Jun 21, 2013
Messages
7
Programming Experience
Beginner
Hi, I would click on button on my webbrowser, but the source code is very strange(for my)

VB.NET:
[COLOR=#000000][FONT=Consolas]<[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]a [/FONT][/COLOR][COLOR=#00008B][FONT=Consolas]class[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"btn btn-small btn-success"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] href[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"#"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] onclick[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"javascript:config_page_pns_call_list({id:'39110',monitored_prefix:'39',monitored_number_no_prefix:'3491906666',service_prefix:'39',service_number_no_prefix:'0694802015',status:'VALIDATED',insert_date:'2013-05-26 17:54:23',validate_date:'2013-05-26 17:55:55',active_until:'2112-05-26 17:54:23',active:'1',flat_sms_until:'null',flat_sms_active:'0',send_email:'1',send_sms:'0',send_all_sms:'null',recall:'0',record_call:'0'})"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]><[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]i [/FONT][/COLOR][COLOR=#00008B][FONT=Consolas]class[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"icon-list icon-white"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]></[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]i[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]>[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] Elenco chiamate[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]</[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]a[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]>[/FONT][/COLOR]

I trying every code, but it doesn't work...

Thank you,
Mattia(i'm italian)
 
Hi, thanks, but on html there is another code similar :
<a class="btn btn-small btn-success" href="#" onclick="javascript:config_page_pns_call_list({id:'31738',monitored_prefix:'39',*​monitored_number_no_prefix:'3457752452',service_prefix:'39',service_number_no_pre*​fix:'0694802015',status:'VALIDATED',insert_date:'2013-05-10 19:29:48',validate_date:'2013-05-10 19:34:37',active_until:'2112-05-10 19:29:48',active:'1',flat_sms_until:'null',flat_sms_active:'0',send_email:'1',se*​nd_sms:'0',send_all_sms:'null',recall:'0',record_call:'0'})"><i class="icon-list icon-white"></i> Elenco chiamate</a>
 
You probably need to learn a bit about HTML. The '<a>' tag is shourt for 'anchor' and is specifically a hyperlink, i.e. the most fundamental thing in all of HTML. For instance, 'Reply' link under this post is an anchor tag. Normally they contain a URL in their 'href' attribute but they can also contain some JavaScript in their 'onclick' attribute. I've shown you what to do to click the link programmatically. If there's a problem, perhaps you could explain what it is.
 
hi, thnks for the reply. I'm beginner, i'm italian so i don't understand very well english, but i try..
I've seen your link, but i don't understand how to using that code for my problem. I try to explain.
In a page, there is two button with the almost the same code.
I want to click only 1 button,
javascript:config_page_pns_call_list({id: '31738',monitored_prefix:'39',*​monitored_number_n o_prefix:'3457752452',service_prefix:'39',service_ number_no_pre*​fix:'0694802015',status:'VALIDATED' ,insert_date:'2013-05-10 19:29:48',validate_date:'2013-05-10 19:34:37',active_until:'2112-05-10 19:29:48',active:'1',flat_sms_until:'null',flat_sm s_active:'0',send_email:'1',se*​nd_sms:'0',send_al l_sms:'null',recall:'0',record_call:'0'})
I think(maybe) your link click the href, but in this case is # ...
I hope i was clear.
Thanks
 
Hi,

I agree with jmcilhinney, but I think I have spotted what you are on about. I notice the ID's are different on the two HTML posts so you can use the OuterHtml property to interrogate each link to see if it is the one you want. i.e:-

VB.NET:
If ele.OuterHtml.Contains("id:'39110'") Then
  MsgBox("This is the Button To Click")
End If

Cheers,

Ian
 
Cattura.PNG

For Each ele As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a") If ele.OuterHtml.Contains("id:'39110'") Then
MsgBox("This is the Button To Click")
End If


Next
I used this code, but the msgbox show when webbrowser navigate atthe page of 2 buttons
 
Hi,

You are going to have to help us to help you since we have no access to your full HTML. On the basis that all you said was:-

no, it doesn't select the correct link

But the message box does show then I the only assumption I can make is that something IS being selected. So:-

1) Have you made sure the page is fully loaded after your Navigation?
2) Do you need to expand / change the criteria of the Contains method to make sure you are not accidentally picking up the wrong Link?

Cheers,

Ian
 
i have resolved with an ugly method
SendKeys.Send("{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{TAB}" & "{ENTER}")

Thanks you all
 

Similar threads

Back
Top