开发者

Coded UI Test with web browser popup

开发者 https://www.devze.com 2023-04-06 21:30 出处:网络
I\'m trying to use the Coded UI Test to control an web application (which I don\'t have soruce code for) to generate input data for my application (filling in a form etc).

I'm trying to use the Coded UI Test to control an web application (which I don't have soruce code for) to generate input data for my application (filling in a form etc).

At a certain point, the web app opens a new windows, and the process of filling in continues in this new browser windows. The trouble is that I cant seem to get the UI test code to "move" or discover that a new window is open. It searches for the next item in the old windows, and therefor开发者_StackOverflow中文版e does not find it.

Is there a way to "move focus" to the newly opened browser window?

Using VS 2010, IE9


This reply may be a little late but I've had some success with the following approach:

Inspired by a PluralSight course on Selenium with CodedUI, I created a class called Browser which features a public, static instance of the BrowserWindow object. In that class I have an Initialize() method which assigns my static BrowserWindow instance the value of BrowserWindow.Launch("yourUrlHere"). When I click on a link that opens in a new window and I have to "switch focus" to the new window, I just reassign my static BrowserWindow object the value of BrowserWindow.Locate("windowTitleGoesHere"). Now if I have to search for an element on the page with the browser window as my search context, I always have the correct browser window. When that window closes, I simply reassign my static BrowserWindow object back to the main window using the BrowserWindow.Locate("windowTitleGoesHere") method.

HTH


You may specify parent for controls you search. So, all you need:

1) keep track of open IE windows (you may find them by title, HWND etc.)

2) store these windows as a couple of BrowserWindow variables.

3) search for all the controls like that:

HtmlHyperLink hl = new HtmlHyperLink(window2);
// rest of specification

4) you get your controls in the window you need

You will need some changes to your tests if you use recorder (we write out tests and UIMaps from scratch because recorder generates low-quality code).

0

精彩评论

暂无评论...
验证码 换一张
取 消