0

in webbrowser control a booking website. when i search A To B it give list of items with price. (price is a radio button) when i click radio button. a new div created after some process a submit button named "submitButton0" comes on webpage. on same web page. website location not changed. i want to invoke click of submitButton0.

problem is that. webBrowser1_DocumentCompleted Event has been done. but that time submitButton0 not in page. pragmatically readio button has been click. after some process a submitButton0 comes on page. as submitButton0 comes i want to invoke its click quickly.

what is the solution of it?

Braheen
  • 29
  • 1
  • 1
  • 8

1 Answers1

0

but that time submitButton0 not in page

Which probably means that the buttons are added by Javascript. There's no way to synchronize with script execution, you need to poll. Enable a timer in the DocumentCompleted event handler and in the Tick event check if the DOM was changed enough to allow calling InvokeClick() reliably.

Do check if the site owner makes a web service available. The fact that buttons get added later is a fairly strong hint that the site's TOU does not permit automation. And a service makes your app much more resilient to web page changes. The DOM polling trick is pretty much guaranteed to break sooner or later.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536