0

我需要在 firefox 浏览器中打开 winform 应用程序的链接。然后我想自动完成表单的输入(如用户名和密码)并生成一个按钮单击(例如用于提交表单的登录按钮)。

我目前正在使用 Interop.SHDocVw.dll 对 IE 进行同样的思考,但我需要一个 firefox 实现。Mozilla的浏览器有这样的dll吗?我需要开发插件吗?或者我可能不得不使用 UI 测试框架?

感谢您的回答!

布鲁诺

4

1 回答 1

0

So I start Firefox using Process start:

Process.Start("firefox.exe", "http://www.mywebsite.com");

I then use USER32.DLL to find and focus on the Firefox window:

// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

private void btnEnterText_Click(object sender, EventArgs e)
    {
        var handle = FindWindow("MozillaUIWindowClass", "Environnement de recette 1.4.0.3 - Mozilla Firefox");
        SetForegroundWindow(handle);
        SendKeys.SendWait(txtEntry.Text);
    }

I found the window's class and title thanks to spy++.

So my problem no is to move to the next input on the page... when I use this:

SendKeys.SendWait("{TAB}");

it moves the focus as is I pressed TAB 2 times.... Does anyone knows what's happening ?

于 2011-03-23T11:50:44.507 回答