質問

Is it possible to get selected TextBox using Watin browser.

Example:

Like in webbrowser Control we can put code behind mouse click event and get the mouse position etc.

Can we do the same here ? If not can we atleast get the selected textbox value when button presses? So i click a TextBox on the browser and i open my winform App and press a button it should automatically get the value of text field. I know we can get it by name or id as below:

string phone = fx.Frames[0].TextField(Find.ById("testPhone")).GetValue("value").ToString();

But can we do something like:

string phone = fx.Frames[0].SelectedTextField.GetValue("value")
役に立ちましたか?

解決

Something to try, although it will be a bit convoluted.

A) In the WinForm app tie the button click to a call to a WatiN procedure.

B) In the WatiN procedure

  • Attach to the open IE browser
  • Have a javascript method that finds the Textbox that has focus and gets the value of that textbox. Another approach would be to use WatiN to get all the textfields then loop through them all looking to see which has focus, and get the value that way.
  • Return the text value as the return value to the WinForm app.

In theory, I believe all this to be possible though I have no specific experience tying a WinForm app to call a WatiN procedure.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top