How to click a 'show more' label with vb which has a embedded java script

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 10
Reputation: lalchetian is an unknown quantity at this point 
Solved Threads: 0
lalchetian lalchetian is offline Offline
Newbie Poster

How to click a 'show more' label with vb which has a embedded java script

 
0
  #1
Jun 17th, 2009
[code=html]
  1. <A class=F11 id=moreFF4Link style="DISPLAY: inline" onclick="showMoreFF4('on');clickTrackSwbdAttr('BP:Attributes:Additional Info:Show More','Trattoria-Pizzeria-Roma Inc','Pizza Restaurants, Restaurant Management &amp; Consultants')" href="javascript:void(0);"><BR>Show More &gt;</A>

This is the html of that page. I am looking forward to clicking on 'show more'
I am using a instance of Ie to open this page, As this is supposed to back end process I can't use sendkey
Any other way to get around?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: How to click a 'show more' label with vb which has a embedded java script

 
0
  #2
Jun 19th, 2009
Any other way to get around?
Use web browser control.

Here's your (simplified and modified) HTML
  1. <html>
  2. <script>
  3. function showMoreFF4()
  4. {
  5. alert('foo');
  6. }
  7. </script>
  8. <body>
  9. <A id=moreFF4Link style="DISPLAY: inline" onclick="showMoreFF4()" href="javascript:return(0);"><BR>Show More &gt;</A>
  10. </body>
  11. </html>
And the code to "click" that link
  1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. ' Load test page
  3. WebBrowser1.Navigate("http://127.0.0.1/test.html")
  4. End Sub
  5.  
  6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7. '
  8. Dim Link As HtmlElement
  9.  
  10. ' Get element
  11. Link = WebBrowser1.Document.GetElementById("moreFF4Link")
  12. ' Found?
  13. If Link IsNot Nothing Then
  14. ' Call method
  15. Link.InvokeMember("onclick")
  16. End If
  17.  
  18. End Sub
If you want to use external browser, you can't access the document itself. You could try to send a mouse click. Google http://www.google.com/search?q=send+mouse+click+vb.net but I doubt a bit you'll find a reliable method to send a mouse click exactly where you want to.

HTH
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 10
Reputation: lalchetian is an unknown quantity at this point 
Solved Threads: 0
lalchetian lalchetian is offline Offline
Newbie Poster

Re: How to click a 'show more' label with vb which has a embedded java script

 
0
  #3
Jun 20th, 2009
The query was for vb and not vb.net.

There's some problem with this loop
visual basic Syntax (Toggle Plain Text)
  1. If Link IsNot Nothing Then
  2.  
  3. ' Call method
  4.  
  5. Link.InvokeMember("onclick")
  6.  
  7. End If

it gives an error 424: object required
and yah i can't find htmlelement in vb and hece used htmlanchorelement

Thanks for help
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: How to click a 'show more' label with vb which has a embedded java script

 
0
  #4
Jun 21st, 2009
The query was for vb and not vb.net.
This is VB.NET forum.

There's some problem with this loop
It's not a loop, it's an If statement

it gives an error 424: object required
It has a test If Link IsNot Nothing Then to ensure that Link variable is an object. So it must be InvokeMember("onclick") part that causes the error. That method doesn't produce an error even if the member (onclick in this case) isn't found. It seems that you've slightly modified the code and run it with VB6, am I right?
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 10
Reputation: lalchetian is an unknown quantity at this point 
Solved Threads: 0
lalchetian lalchetian is offline Offline
Newbie Poster

Re: How to click a 'show more' label with vb which has a embedded java script

 
0
  #5
Jun 21st, 2009
for counter=1 to 3
print ("sorry")
next

1) I can't find a vb forum here

2) as you would have already known, am a beginner and was out of my mind then

3) If Link IsNot Nothing Then was giving a error as invalid use of property so removed it,
so you're right the problem is with InvokeMember("onclick")
any solutions.....!!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: How to click a 'show more' label with vb which has a embedded java script

 
0
  #6
Jun 21st, 2009
I can't find a vb forum here
Here's DaniWeb's Visual Basic 4 / 5 / 6 forum.

as you would have already known, am a beginner and was out of my mind then
That's ok

any solutions.....!!!!
VB6's web browser control does not have either GetElementById or InvokeMember methods. I can think of only two solutions: try to google (I gave link before) how to send mouse clicks, or the better one, close this thread and re-post this question to DaniWeb's Visual Basic 4 / 5 / 6 forum.

I still have VB6 installed so I took a quick look, but I didn't find any solution with VB6, sorry!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC