简体   繁体   中英

How to encapsulate Watir browser instance in a GUI using Ruby?

Basically, I'm programming a testing application for multiple sites using Watir. However, there are end-users (who can be assumed to be the typical user unfamiliar with the command line, using Windows). Now, I want to give them something to watch, say, what's going on visually (at the clients request, sigh ).

I'll be making a GUI, that displays the form data being used to test (random info for forms, username, names, etc) the site and what's going on. I want a preview window, like the WebBrowser class in C#.NET.

Is there a concise way to restrict/encapsulate (idk what other phrase to use) a browser instance in a GUI (wxRuby, Shoes, etc.) w/ Watir (or Watir-WebDriver) in Ruby?

(Note: This is to be run on a Windows machine)

This is a bit of a tall order. Watir itself is just running from the command line, so you'd need to see if there is a way to do what you want with a command line window in the OS you are using. But then watir invokes an instance of the browser (which with Watir-webdriver can be a large number of different browsers), and each of those is their own beast, reacting with the OS and UI in their own way, and I've no idea who you might 'wrap' IE or Chrome or Firefox in the way you are describing..

It MAY be easier from that perspective to see if there would be a way to wrap the interface of a virtual machine perhaps? (maybe some way to do this with virtualbox or vmware?)

This seems like a pretty quirky request if you ask me, I'm having a hard time seeing the business value in what you are being asked to do.

If you're using watir-classic, you can hide your IE window with:

ie = Watir::Browser.new
ie.visible = false

That might be helpful if your requirement is to hide the browser window and only display a console window for logs/status messages.

If you're using Watir WebDriver/Selenium, I'm not sure if a similar method is available. In a quick search I didn't see anything.

The IWebBrowser2 "visible" property may be useful - not sure how hard it would be to patch this in to Watir WebDriver if it doesn't already support it:

http://msdn.microsoft.com/en-us/library/aa752082(v=vs.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM