0

I am making a bot which visits to a specific url, give the input in form and submit it by clicking to submit button...

Let me explain you my situation. When I start my bot, firstly it visits the URL, after web page is loaded, I have to check one radio button manually there and after this I press submit button (windows form control button to fill all fields of web page and submit it also by using invoke click method) to submit form.

I am using Web browser control (coding in C#.NET windows form) and the problem is when I click on a radio button, a pop up window pops up with the heading "Script Error" and says enter image description here

Below is the tag of radio button (on which error pops up) which I copied by using IE development tool.

<input name="array(BlastDatabaseType)" onchange="changeQuestion(); changeAlgorithms();"
type="radio" value="Proteins"/>

This error don't occur on normal web browser. I want to solve this error not to hide.

Saad Qureshi
  • 389
  • 4
  • 19
  • I guess you want to submit the page by programmatically clicking on submit button ,but the JavaScript error is causing problems ? – DayTimeCoder Sep 17 '12 at 20:11

2 Answers2

4

What I have understood from your question that you need to fix the javascript error which is generated due to Web browser Control,

There are two basic solutions,

1) Force the Web Browser control to emulate the latest IE browser. You need to make a registry change for this ,and you will be able to use the IE browser installed on the PC.

Adapted from Mikel Solution
You can use a meta tag <meta http-equiv="X-UA-Compatible" content="IE=9" > inside the HTML page.

But its better to add a registry entry to: (goto > start > run > type 'regedit' enter)

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER) > SOFTWARE > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION > contoso.exe = (DWORD) 00009000

use 10000 (0x02710) for Internet Explorer 10

2) Use the GeckoFX wrapper ,it wraps the Gecko engine,
Download the GeckoFX wrapper
Download the XulRunner

First extract the GeckoFX and read the readme.txt file.

Add reference of the Gecko.dll in you toolbar ,and then drag and drop the control on your Form.

public Form1()
    {
        InitializeComponent();
        //you need to extract the Xulrunner in the soultion directory
        //  (preferable) b/c wrapper relies on these dlls.
        Skybound.Gecko.Xpcom.Initialize(@"C:\Xulrunner");
    }

    private void Form1_Load(object sender, EventArgs e)
    {
       geckoWebBrowser1.Navigate("http://tritrypdb.org/tritrypdb/"); 
    }


Other useful Links:
http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation
Will the IE9 WebBrowser Control Support all of IE9's features, including SVG?

Community
  • 1
  • 1
DayTimeCoder
  • 4,294
  • 5
  • 38
  • 61
  • 1
    Keep in mind that there are two different versions of FEATURE_BROWSER_EMULATION. There is one for 64-bit apps and one for 32-bit apps. See http://stackoverflow.com/a/42864875/167920 – Wallace Kelly Mar 17 '17 at 18:41
0

IE handles differently the onchange event. IE only fires the onchange event when the element loses focus.

If I understood your question correctly, You might want to use onkeypress event instead.

defau1t
  • 10,593
  • 2
  • 35
  • 47