Double number of items returned by Desktop.ChildObjects - browser

I am trying to get all the open Browser objects using QTP11.
The code I use is the following:
Set descBrowser = Description.Create
descBrowser("micClass").Value = "Browser"
Set objChildren = Desktop.ChildObjects( descBrowser )
During testing, i have two IE Browser windows open, but the collection returned by the code shows four found items. I checked the running processes also, which show the correct number of 2 processes running.
I have also checked with 3 Browsers open, in which case it shows 6 objects matching the descrption.
Can anybody explain why this could be happening?

UFT 11.52 + Win7
I had tried several strategies to get this done(PIDs, Title, HWND, browser(index)), and still not success, I am not sure on whether this patch is already there.
What I can picture is that for a simple closing task the UFT is also having issues as it says "Object not visible" when I try to close the Browser() object crashing down the test in random fashion.
The best result was a bunch of already alive IExplorer windows(Tabs) oppened.
Can someone provide steps to check the installed patches ?

I see the same behaviour (only for IE not Firefox).
A workaround for this can be to filter out duplicates. For IE if you compare the objChildren(i).GetROProperty("hwnd") you can filter out those with the same value but this will not work if you also use Firefox since in Firefox if you have multiple tabs they all have the same hwnd.
If you have to take FF into consideration you can filter out duplicates using the CreationTime property (instead of the hwnd).

I had the same issue and I had to back out patch QTPWEB_00090 to get it to work. See if you have that QTP patch installed and back it out.

This is fixed in QTPWEB_00107 - Web Browser Control Recognition in Windows Explorer

Related

How To identify Object After Navigation in Coded UI

i m new to MS Coded UI Automating, my Question is.
When i launch my Browser (IE) and fill the detials and then click on submit button. it takes me to new page where i get an error called action cannot be perform on hidden objects
i am using MS 2012 Premium Verison
thanks
Limited information to go on, but have you checked out this the fallowing?
http://blogs.msdn.com/b/visualstudioalm/archive/2013/09/17/coded-ui-mtm-issues-on-internet-explorer-with-kb2870699.aspx
Coded UI error: The following element is not longer availabe
This might be the annoying side effect of Windows Update KB2870699, update 4 for VS2012 is supposed to fix this but an alternative work around is simply to uninstall this update.

Watir Webdriver fire_event onmouseover no longer working

I've been using Watir to automate testing of my companies primary web app. The tests require a javascript dropdown menu fired by mouse over, and a link on that menu to be clicked.
$browser.link(:id=> 'element').fire_event "onemouseover"
Was working perfectly until we changed the look and feel of the app. The changes made to the look in feel didn't appear to change in any way how the HTML looks and the menus work. Everything else is working fine with Watir.
I've tried using a solution that seemed to work for others, by including:
class Watir::Element
def hover
assert_exists
driver.action.move_to(#element).perform
end
end
and using
browser.div(:id => "someId").hover
But when the menus appear they instantly go away before the driver has a chance to click the menu item.
browser.div(:id => "someId").hover
sleep 3
Will solve the problem. I have faced same issue and sleep solved it :)
I've managed to get around this one (provided the site uses jquery) by using execute_script to fire off some jquery to override the visibility on the 'hidden' menus. See this answer https://stackoverflow.com/a/8392467/409820 for more info
Needing to do that was one reason I and others requested the .hover method, so that is also something you could try.
(my scripts are still using that particular trick because a) it's working, and b) I'm working on other stuff right now and don't have a pressing need to fiddle with them.

Capybara Cucumber test fail to find xpath when browser is minimized

I'm running a scenario where form fields are automatically filled in with invalid values which trigger some javascripts to show warnings under each incorrectly filled field when I blur.
The test passes when the browser is in focus. It finds the xpath with the "expected warning" that I pass. But if I minimize or just click on another application, it fails to find the xpath.
I'm running Firefox 3.6 (going to update it soon) and the way I'm doing to find the xpath is by using "page.should have_xpath(xpath)"
Does anyone have any idea how what might solve this? It's really important for me to run it with the browser minimized.
Edit and alternative solution:
I guess the timing issue that occurs in events such as blur followed by finding a certain xpath in a minimized browser inherent to the driver itself. Therefore, I decided to run the tests in a Virtual Frame Buffer using xvfb in Linux and it seems to be working really well. I'm planning on applying this to be triggered by Hudson/Jenkins whenever a change is committed.
Could it be a timing issue? Perhaps if the browser isn't frontmost and maximised, the rendering is not happening quickly enough for the content be present when Capybara checks for it.
Also: How are you triggering the blur event?

Adapting Modal Dialog Script to Firefox

I'm adapting my regression tests to test a web app in firefox. The biggest stumbling block seems to be how to automate the modal dialogs in firefox.
In ie I use variations of the script below, but it doesn't work in Firefox. Is there an alternative that will work in both ie and firefox?
popup=Thread.new {
autoit=WIN32OLE.new('AutoItX3.Control')
ret=autoit.WinWait(title,"",60)
if (ret==1)
puts "There is popup."
autoit.WinActivate(title)
button.downcase!
if button.eql?("ok") || button.eql?("yes") || button.eql?("continue")
autoit.Send("{Enter}")
else
autoit.Send("{tab}")
autoit.Send("{Enter}")
end
elsif (ret==0)
puts "No popup, please check your code."
end
}
at_exit { Thread.kill(popup) }
end
button.click_no_wait
check_for_popups("Message from webpage", "OK")
Given you are talking about a javascript created dialog, I really have to ask, is there a lot of value in actually testing those?
It basically amounts to testing the functionality of the browser
If you are talking about the type of popups described here http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups then I think the first solution, of overriding the javascript may well be your best cross platform option.
The problem with modal dialogs like this is that they are basically a UI even that is happening out at the OS level, it's no longer inside the browser DOM, and thus you need tools that are specific to the OS (like stuff that depends on win32ole, such as autoit) in order to generate the necessary interaction with the native UI and click buttons, send keystrokes etc. Most of the solutions presented should I think work with FF on windows (with proper renaming of expected window titles etc) but would fail on a mac or *nix OS. That means you need a different solution for each OS, which is a pain.
It might simply be easier to verify you can find the proper stuff that would fire the event in the HTML of the page, so you know an event WOULD be fired, and then override things so it isn't. After all it's not really your job to validate that the browser pops up a local dialog when something like alert('This is an alert box') is invoked in javascript. Your concern is that in the HTML a given element is coded to fire off the event that is needed e.g. that there's something like this onClick = 'javascript:x = confirm('Do you really want to do this');" affiliated with the element
I am experiencing a similar problem in Firefox (and I do have to test in Firefox). I can see the code calling the Javascript but when I try to override as described above nothing happens. Is there any kind of a workaround for this? Anticipated updates to Watir? ;-)

SharePoint Error - Datasheet View refuses to show up!

Recently the DataSheet view of my list refuses to dispaly. I tried numerouse times and with no luck. Other lists works just fine, except for this one.
there is a Java error message on the left bottom corner of the screen that disapears in 2 seconds, then it renders the list in Standard view any time you try it.
I even created a new Datasheet View - the result a Standard View.
Any suggestions?
Thanks,
Here is a MS site regarding the data sheet view and why it may not be available - http://support.microsoft.com/kb/909506
The error occured after we installed an add-on to restrict users permissions. It looks like this solution afftects the functionality of the site (we tested it for a few days then disable it). Will wait for an improved solution.
http://www.codeplex.com/SPViewPermission

Resources